SuperWebSocketWeb (Chat window) sample on IE 9.0 / Silverlight bridge

Jul 6, 2012 at 10:08 AM

Hi,

I'm trying to use SuperWebSocket in a webproject that must be supported on IExplorer (9.0 at least). I have been trying to run the Chat sample on the default (source) download package simply by replacing

>Response.Redirect(string.IsNullOrEmpty(returnUrl) ? "~/LiveChataspx" : returnUrl);     by

>Response.Redirect(string.IsNullOrEmpty(returnUrl) ? "~/LiveChatWithBridge.aspx" : returnUrl);

on the Default.aspx.cs code-behind file.

Then, when accessing the web application by using Internet Explorer 9.0 I'm getting the following message:

* Connecting to server ..
# [net_winsock_10013] Argumentos: Las cadenas de recursos de depuración no están disponibles. La clave y los argumentos suelen proporcionar suficiente información para diagnosticar el problema. Vea http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.10411.00&File=System.Net.dll&Key=net_winsock_10013

Any suggestion? Be aware I'm quite new at C# / SuperWebSockets / Silverlight programming so probably I have some missunderstanding.

Thanks in advance.

Coordinator
Jul 6, 2012 at 10:41 AM

You should setup policy file.

There are two options:

1) put the policy file clientaccesspolicy.xml in the root of the site of 80 port with the same host with your running website

2) setup a policy server with SuperSocket

http://supersocket.codeplex.com/SourceControl/changeset/view/79911#1453558

 

 

Jul 9, 2012 at 8:36 AM
Edited Jul 9, 2012 at 8:41 AM

Firstly, thanks for your quick response, but currently the error message remains...

After downloading the project, all I have done is what follows:

1. Replace >[Response.Redirect(string.IsNullOrEmpty(returnUrl) ? "~/LiveChataspx" : returnUrl);]     by >[Response.Redirect(string.IsNullOrEmpty(returnUrl) ? "~/LiveChatWithBridge.aspx" : returnUrl);] in the file "Default.aspx".

2. Create a new directory named "Policy", which contains a single file named "silverlight.xml" with the following content:

<?xml version="1.0" encoding="utf-8" ?>
<cross-domain-policy>
  <site-control permitted-cross-domain-policies="all"/>
  <allow-access-from domain="*"/>
  <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

3. Modify the "Application_Start" method within the file "Global.asax.cs" as follows:

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

            var policyServer = new SilverlightPolicyServer();

            var config = new ServerConfig();
            config.Name = "SilverlightPolicyServer";
            config.Mode = SocketMode.Async;
            config.Ip = "Any";
            config.Port = 2011;
            config.Options = new System.Collections.Specialized.NameValueCollection();
            config.Options.Add("policyFile", "Policy\\silverlight.xml");

            policyServer.Setup(new RootConfig(), config, SocketServerFactory.Instance);

            policyServer.Start();
        }

4. Right click on the project name > Debug > Start new Instance.

It works properly under firefox, but when I access "http://localhost:8247/LiveChatWithBridge.aspx" by using IE9 I still get the same error:

* Connecting to server ..
# [net_winsock_10013] Argumentos:  Las cadenas de recursos de depuración no están disponibles. La clave y los argumentos suelen proporcionar suficiente información para diagnosticar el problema. Vea http://go.microsoft.com/fwlink/?linkid=106663&Version=5.0.10411.00&File=System.Net.dll&Key=net_winsock_10013

Any idea of what can I be doing wrong?

Again, thanks in advance.

Coordinator
Jul 9, 2012 at 8:52 AM

OH,

The Silverlight or Flash policy server's port is fixed!

<server name="SilverlightPolicyServer"
                    serviceName="SilverlightPolicyService"
                    ip="Any" port="943"
                    mode="Async"
                    receiveBufferSize="32"
                    maxConnectionNumber="100"
                    policyFile="Policy\silverlight.xml"
                    clearIdleSession="true">
            </server>

Silverlight's socket pilicy server;s port is 943!

Jul 9, 2012 at 9:39 AM

Modified (thanks!):

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

            var policyServer = new SilverlightPolicyServer();

            var config = new ServerConfig();
            config.Name = "SilverlightPolicyServer";
            config.Mode = SocketMode.Async;
            config.Ip = "Any";
            config.Port = 943;
            config.Options = new System.Collections.Specialized.NameValueCollection();
            config.Options.Add("policyFile", "Policy\\silverlight.xml");

            policyServer.Setup(new RootConfig(), config, SocketServerFactory.Instance);

            policyServer.Start();
        }
But the same error persists. Do you detect any step that could I be forgetting? Do you think the source of the problem could be something not related with the policy server?

Coordinator
Jul 9, 2012 at 9:42 AM

Could you clear the browser's cache and then connect again? At the same time you'd better monitor the logs to check the server's running status.

All logs files are located in the subdirectory "Logs".

Jul 9, 2012 at 11:05 AM

Clearing browser's cache hasn't work.

When forcing the system to not to find the policy file:

e.g.:    > config.Options.Add("policyFile", "Policy\\silverlightSSSS.xml");

I get the following log line: 2012-07-09 11:57:22,803 [3772] ERROR SilverlightPolicyServer - The specified policyFile doesn't exist! C:\Users\Marc\Desktop\SuperWebSocket(0.6).Source(1)\Samples\SuperWebSocketWeb\silverlightss.xml

Then, I suppose that the system properly finds the file so it doesn't output any lines when the code line is written correctly.

I have also tried to execute the project on another computer getting the same error.

Looking at what I have done, don't you detect if I'm missing any step or something?

Thanks and excuse me to be so annoying...

Coordinator
Jul 9, 2012 at 4:07 PM

Apparently, the policy file path is incorrect!

If you set config.Options.Add("policyFile", "Policy\\silverlight.xml");, you should make sure the file "Policy\silverlight.xml" does exist!

Jul 11, 2012 at 12:56 PM
Edited Jul 11, 2012 at 1:57 PM

I have made some progress... even when it still doesn't work!

Firstly, I have downloaded a very useful program for testing purposes which can be found there in order to test TCP connections.  I have tried to send a TCP message to port 943 with the text: "<policy-file-request/>" and I have properly received the policy file, so I conclude that the policy server works properly. Then, I have tried to simulate the server (by using the program to listen to port 943) and I have realized that the application isn't requesting the policy file!

I have followed the same process by replacing silverlight by flash (port 843 instead 943, among other changes [using "web-socket-js"....]), getting the same result: policy server working well, but with the application doesn't requesting for the policy file.

I'm executing the project directly on Visual Studio 2010 SP1 by right clicking on the project name > Debug > Start new Instance, of course in localhost all in the same computer. I'm using Silverlight 5, Windows 7 Pro 64 bits...

Any idea of what could be happening?

Thanks.

UPDATE: I have tried to install IIS 7 server and located the "clientaccesspolicy.xml" file at localhost:80/clientaccesspolicy.xml (C:\inetpub\wwwroot\clientaccesspolicy.xml) and now it works even in IE9! But now I really can't understand why both approaches aren't trying to request the policy file by using port 843/943 and the policy server. Any suggestion will be wellcome...