Running chat sample in IIS

May 17, 2011 at 9:03 AM

I cannot get your web server app (the one with LiveChat.aspx) to run in IIS. LiveChat.aspx runs but never connects after entering in a username. The sample you have provided runs in the VS's built-in web server. However, I want the sample to run as a www.superwebsocket.com under port 80. Any idea how to make that work? I use a DNS tool to map a local IP address to superwebsocket.com but the problem seems to be with port 80.

Coordinator
May 17, 2011 at 9:07 AM
The sample website can work on port 80. But you cannot use 80 as WebSocket port.
You should choose another one, and then take care of the firewall issues.
Dec 28, 2011 at 2:08 PM

I have similar issue, on my web.config I have:

      <server name="SuperWebSocket"              serviceName="SuperWebSocket"              ip="Any" port="3011" mode="Async">      </server>      <server name="SecureSuperWebSocket"              serviceName="SuperWebSocket"              ip="Any" port="3012" mode="Sync" security="tls">

 

And this works on my VS 2010 developement;  however, when I published it to the IIS, it did not work and said that the browser cannot support websocket.  This is rather new, so if you can explain a little more as to what to do with the websocket server port setup.  That would help a lot.  

Coordinator
Dec 29, 2011 at 12:50 AM

If the browser told you "Your browser cannot support websocket!", it's really the browser you were using doesn't support WebSocket.

Not all the browser support the websocket function, what's the browser are you using?

Dec 29, 2011 at 1:12 AM

Thanks for responding.  I use Chrome.  This browser works just fine with VS 2010.  As you mentioned above, I must use different port for WebSocket.  So I chose port 3011 and 3012 respectively as indicated in the web.config file.  You also mentioned "then take care of the firewall issues", can you elaborate on that?

Coordinator
Dec 29, 2011 at 1:16 AM

It is very strange to get the message "Your browser cannot support websocket!" if you use Chrome.

Coordinator
Dec 29, 2011 at 1:21 AM

Does the demo below work for you?

http://websocket.iauto365.com/

Dec 29, 2011 at 2:02 PM

That demo works just fine on my Chrome browser.  I did not find the log file in the physical directory where the web app is deployed.  Apparently the log file was not created.  I checked the folder permission and it is the same as other web app folders that can write to files.  In any event, I was trying to do a demo project for websocket and html 5.  This definitely is a drawback, a failure on my part.

Coordinator
Dec 30, 2011 at 5:59 AM

If so, your server instance hadn't been started.

Please check whether you deploy the code correctly. The startup code locates in global.asax.cs, you can debug it to find out the reason.

Dec 30, 2011 at 3:28 PM

I am still trying to do some debug for my web app.  Any way, I saw another called websocket white board and he used your framework.  He said to add an entry into the hosts file, something like this:  

whiteboard 127.0.0.1

Not sure what it is for.  I tried it similarly for my web app.  But it did work either.

Coordinator
Dec 31, 2011 at 1:30 AM
Edited Dec 31, 2011 at 1:33 AM

No, he just want to navigate the host witheboard to 127.0.0.1(local PC). Please debug into the startup code, it is important to fix your issue. Did you do it?

If you don't know debug the IIS prorcess, please google keywords:  VS+Attach IIS.

Dec 31, 2011 at 5:00 AM

My web app is deployed to a remote 2003 server.  My VS is on another machine.  I am not sure there are any firewall issues to remotely debug.  In any event, I will try to remote debug this and report the result as soon as possible.  I plan to do some more work with project; but until I can get the web app to work in the IIS, it is useless at this point to go on. 

Coordinator
Dec 31, 2011 at 8:34 AM

Debug it in your local IIS first.

Dec 31, 2011 at 9:28 PM

I am having a great difficult in debugging the global.asax.cs file.  It never seems to break at

SocketServerManager.Start()

and  if it does, there is no code even the pdb file is there, because when I right-click on the method and select definition, there is no code display.

Coordinator
Jan 1, 2012 at 3:10 AM

Please setup a new site, and then set the new site's root to be the folder of SuperWebSocketWeb. You needn't publish it. Do you know how to debug IIS process?

Jan 1, 2012 at 4:27 AM

I was able to attach to the IIS process.  But the debug did not break at any breakpoints that I set in the Global.asax.cs in order to step through the code especially the SocketServerManager.Start() method to see why the websocket server instance was not created.

Here is what basically I did:

1.   Created an asp.net web project and referenced all super web socket server dll

2.   Tested using Chrome browser (sending some messages and receiving some messages)

3.  Created a virtual directory in the IIS and pointed it to a physical directory that contains all the files copied from the VS folder (.aspx, web.config, dlls)

4.  Opened Chrome browser and pointed to the url of the virtual directory in the IIS.  The messages were:

Connecting to server ..

Server closed

Secure server closed

 

 

 

 


Coordinator
Jan 1, 2012 at 4:54 AM

To simplify the steps, you'd better follow my instruction.

Did you debug the line:

void Application_Start(object sender, EventArgs e)
        {
            LogUtil.Setup();
            StartSuperWebSocketByConfig();
            //StartSuperWebSocketByProgramming();
            var ts = new TimeSpan(0, 0, 0, 0, 5);
            m_SecureSocketPushTimer = new Timer(OnSecureSocketPushTimerCallback, new object(), ts, ts);
        }

 

Whether the method Application_Start was fired?

If no, please check all basic asp.net issues. In this case, your issue is not related with SuperWebSocket.

If yes, please check the code execution returned in which line.

ANYWAY, debug into the code is very important to fix your issue. 

Jan 1, 2012 at 3:42 PM

I was focusing around the code area that you indicated.  My biggest difficulty at this point is to get the code to stop at the break point in the global.asax.cs.  And it is not happening.  I looked on internet for the global.asax.cs debugging issue and tried a few suggestions but not very successful.  The break points are ok for other code behind except for global.asax.cs

So I will again to debug it.

Coordinator
Jan 2, 2012 at 1:53 AM

You can add lines of code in Applicaion_Start which writes some content to a local file as logging.

Jan 2, 2012 at 4:10 PM

I did basically like that

        void StartSuperWebSocketByConfig()        {            var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig;
            WriteFile("Count:  " + serverConfig.Servers.Count);
            if (!SocketServerManager.Initialize(serverConfig))            {                WriteFile("SocketServerManager.Initialize() failed");                return;            }

.

.

.

It looks like it failed at SocketServerManager.Initialize() method.  I checked the serverConfig.Servers.Count to see if it is null.  It looks the same as in VS development test.  I cannot get into the SocketServerManager.Initialize() method to see why it returns false.

So to recap, the global.asax.cs did fire the start method.

Where can we go from here?

Coordinator
Jan 3, 2012 at 12:30 AM

Check log files, it is in the directory /Logs

Jan 3, 2012 at 3:03 AM

 

System.Net.Trace.log file was never created.  I am not sure when the log file is created or appended.  So I cannot open the file and see what was going on.  There is a log file generated in VS development environment, however.  For some reason, the log file was never created when deployed to the IIS.

Coordinator
Jan 3, 2012 at 3:23 AM

NO, not System.Net.Trace.log.

If the line LogUtil.Setup() run, logging files of SuperSocket will be created in the directory /Logs. Most of errors would be saved in those files.

Did you copy Config/log4net.config to your directory /Config? It is a must if you want to make the logging run.

Jan 3, 2012 at 3:28 AM

System.Net.Trace.log file will not be created or appended until SocketServerManager.Start() method is executed.  For my case, it failed at SocketServerManager.Initialize() method which is way before the SocketServerManager.Start().  Therefore, there will be no log file available for viewing.  So I am kind of stuck.

Jan 3, 2012 at 3:49 AM

Well, there seemed to be some progress.  I am getting the connection now after I copied the Config/log4net.config as you said.  I did not realize that is what cause the problem.  It is working mostly now.

Jan 5, 2012 at 11:51 PM

Hello,

I have success deploying the web socket project to my local IIS.  It ran good.  I then deployed the web project to the IIS on a windows server 2003.  I tried to make sure everything is identical as possible.  I even register the localhost.pfx file.  When I ran on Chrome browser, I got the following error message.  I am not sure what to do next.  Any advice will be welcomed.

 

2012-01-05 18:39:35,246 [13] ERROR SecureSuperWebSocket - Failed to initialize certificate!System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)   at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)   at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)   at SuperSocket.SocketBase.Security.CertificateManager.Initialize(ICertificateConfig cerConfig) in D:\Kerry\Workshop\SuperSocket\v1.4\SocketBase\Security\CertificateManager.cs:line 27   at SuperSocket.SocketBase.AppServerBase`2.SetupCertificate(IServerConfig config) in D:\Kerry\Workshop\SuperSocket\v1.4\SocketBase\AppServerBase.cs:line 3042012-01-05 18:39:35,261 [13] ERROR SuperSocket - Failed to setup server instance!2012-01-05 18:39:35,261 [13] ERROR SuperSocket - Failed to initialize server SecureSuperWebSocket!

Coordinator
Jan 6, 2012 at 12:59 AM

Could you confirm the certificate file(*.pfx) does exists in the path you specified in configuration?

Jan 6, 2012 at 1:45 AM

The localhost.pfx file is in the same directory along with the web.config file.

Coordinator
Jan 6, 2012 at 1:46 AM

What's the certification filepath in configuration?

Jan 6, 2012 at 1:51 AM

 

        <certificate filePath="localhost.pfx"                     password="supersocket"                     isEnabled="true"></certificate>

Coordinator
Jan 6, 2012 at 1:58 AM

Could you config filePath attribute with the absolute file path of the pfx file and then try again?

Jan 6, 2012 at 2:11 AM

I tried the absolute path two ways:

        <certificate filePath="C:\WebSites\Test\WebChat\localhost.pfx"                     password="supersocket"                     isEnabled="true"></certificate>

        <certificate filePath="C:/WebSites/Test/WebChat/localhost.pfx"                     password="supersocket"                     isEnabled="true"></certificate>

I still got the same error.

Coordinator
Jan 6, 2012 at 2:17 AM

I have no idea now.

Did you restart the server?

Jan 6, 2012 at 2:23 AM

I reset iis and tried  again and the result is the same.  I did some looking on the internet and there were some talked about the ISS privillage issue.

Coordinator
Jan 6, 2012 at 2:24 AM

Could you share me with all the log files?

kerry-jiang@hotmail.com

Jan 6, 2012 at 2:45 AM

The only log file that has anything in it is the err.log

debug.log

err.log

2012-01-05 21:38:00,464 [1] ERROR SecureSuperWebSocket - Failed to initialize certificate!System.Security.Cryptography.CryptographicException: The system cannot find the file specified.
   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)   at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)   at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)   at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password)   at SuperSocket.SocketBase.Security.CertificateManager.Initialize(ICertificateConfig cerConfig) in D:\Kerry\Workshop\SuperSocket\v1.4\SocketBase\Security\CertificateManager.cs:line 27   at SuperSocket.SocketBase.AppServerBase`2.SetupCertificate(IServerConfig config) in D:\Kerry\Workshop\SuperSocket\v1.4\SocketBase\AppServerBase.cs:line 3042012-01-05 21:38:00,479 [1] ERROR SuperSocket - Failed to setup server instance!2012-01-05 21:38:00,479 [1] ERROR SuperSocket - Failed to initialize server SecureSuperWebSocket!

 

info.log

perf.log

Coordinator
Jan 6, 2012 at 2:46 AM

Only one information?

Jan 6, 2012 at 2:51 AM

I got a lot more on my local IIS when the web application ran.  On the 2003 server, I deleted all the log files and reset the IIS and ran the web application so the log files can be regenerated with fresh info.  And that is all the info I can see.

Coordinator
Jan 6, 2012 at 2:53 AM

It is strange, because you changed the web.config many times, so the socket server should try starting many times. In this case, many this kind information should be generated.

Jan 7, 2012 at 10:38 PM

Any suggestions on the certificate issue?  I finished my chat project; but it only works on my own machine IIS.  Until i can get it to work on server 2003 IIS, it is not going to be used.

Coordinator
Jan 8, 2012 at 1:58 AM

Did you check the log deeply? Can you answer my question in my previous post?

Mar 11, 2013 at 9:59 AM
While running the project, I got a message i.e Message from Website [object event] and closing the ws.onclosing..
How can I achieve this..??
Please help me..
Mar 11, 2013 at 10:28 AM
Hi... Is it working for you?? If yes, please guide me... I tried to run this since one day...
Coordinator
Mar 11, 2013 at 10:33 AM
What? I cannot understand your problem!
Mar 11, 2013 at 11:16 AM
Edited Mar 11, 2013 at 11:16 AM
Actually I tried to run the whiteboard application in my IIS. while browsing the site, I got a message like Message from Website [object event] and after that, my web-socket connection was closed. Need to change any settings in web.config? Is there any particular process to run this application?? Guide me please..