maxCommandLength config option not having effect

Dec 30, 2014 at 1:34 PM
Edited Dec 30, 2014 at 8:15 PM
Hello,

This is related to this.
Since the connection is going to be between a xaml application and the browser, locally, I am not going to stress about the packet's length and let TCP make it's wonders. I made a new project, referenced the .dlls and copied the config files from the E-CustomSession sample and adjusted. Until I added the config file, the application didn't want to start up. Therefore, the config file must be referenced.

I modified my config file and it looks like this, with no effect:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="superSocket" type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine"/>
  </configSections>
  <appSettings>
    <add key="ServiceName" value="TutorialWebSocket"/>
  </appSettings>
    <superSocket>
        <servers>
            <server name="TutorialWebSocket"
                    serverTypeName="WebSocketService"
                    ip="Any" port="2012"
                    maxCommandLength="1024000">
            </server>
        </servers>
        <serverTypes>
            <add name="WebSocketService"
                 type="TutorialRecorder.Websocket.WebSocketServer, TutorialRecorder.Websocket.WebSocketSession" />
        </serverTypes>
    </superSocket>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
</configuration>
And here are my logs:
err.log
2014-12-30 14:10:03,536 [4400] ERROR WebSocketServer-36610825 - Session: 2a8d3202-c572-44f6-ad42-359f595be216/127.0.0.1:52530
Max request length: 1024, current processed length: 2698
2014-12-30 14:10:39,417 [5224] ERROR WebSocketServer-36610825 - Session: 478408cb-8941-4f20-99e1-d53395db4ef2/127.0.0.1:52559
Max request length: 1024, current processed length: 2698
--i modified it here.-
2014-12-30 14:18:58,845 [11588] ERROR WebSocketServer-36610825 - Session: f9487a60-1e91-4f91-a4a1-493e79d0ec1e/127.0.0.1:52836
Max request length: 1024, current processed length: 2698
2014-12-30 14:23:40,615 [4404] ERROR WebSocketServer-14854669 - Session: d962ec62-8add-4ec4-80cd-fd38715072e6/127.0.0.1:53050
Max request length: 1024, current processed length: 2698
info.log

2014-12-30 14:23:16,724 [2752] INFO  WebSocketServer-14854669 - The server instance WebSocketServer-14854669 has been started!
2014-12-30 14:23:34,506 [11092] INFO  WebSocketServer-14854669 - Session: d962ec62-8add-4ec4-80cd-fd38715072e6/127.0.0.1:53050
A new session connected!
2014-12-30 14:23:40,624 [4404] INFO  WebSocketServer-14854669 - Session: d962ec62-8add-4ec4-80cd-fd38715072e6/127.0.0.1:53050
This session was closed for ProtocolError!
2014-12-30 14:24:03,616 [7240] INFO  WebSocketServer-14854669 - The server instance WebSocketServer-14854669 has been stopped!
Although I changed the config file, it still asks for the default value, 1024. What is the problem?

Thank you
Jan 3, 2015 at 6:24 PM
Edited Jan 3, 2015 at 6:25 PM
I found the solution from here, here and here.
You don't necessarily need to create a config file SuperSocket.SocketService.exe.config. Nor do you have the option MaxRequestLength according to this. So, you need MaxRequestLength instead of maxCommandLength.
Here is my final code:
        private void Work()
        {
            Console.WriteLine("WebSocketServer is starting!");
            appServer = new MyNamespace.Websocket.WebSocketServer();

            SuperSocket.SocketBase.Config.RootConfig r = new SuperSocket.SocketBase.Config.RootConfig();
            SuperSocket.SocketBase.Config.ServerConfig s = new SuperSocket.SocketBase.Config.ServerConfig();
            s.Name = "SuperWebSocket";
            s.ServerTypeName = "WebSocketService";
            s.Ip = "Any";
            s.Port = 2012;
            s.MaxRequestLength = 1024 * 1000 * 1000;
            SuperSocket.SocketEngine.SocketServerFactory f = new SuperSocket.SocketEngine.SocketServerFactory();

            appServer.Setup(r, s, f);

            appServer.NewMessageReceived +=
                new SuperSocket.SocketBase.SessionHandler<Websocket.WebSocketSession, string>(
                    appServer_NewMessageReceived);
            appServer.NewSessionConnected +=
                new SuperSocket.SocketBase.SessionHandler<WebSocketSession>(
                    appServer_NewSessionConnected
                    );


            Console.WriteLine();

            //Try to start the appServer
            if (!appServer.Start())
            {
                Console.WriteLine("Failed to start!");
                Console.ReadKey();
                return;
            }

            Console.WriteLine("The server started successfully!");
        }
Marked as answer by CatalinWeb on 1/3/2015 at 11:26 AM
Coordinator
Jan 3, 2015 at 6:38 PM
Yes,
it is a change from SuperSocket 1.5 to 1.6.
maxCommandLength => maxRequestLength
Jan 4, 2015 at 8:35 AM
kerryjiang wrote:
Yes,
it is a change from SuperSocket 1.5 to 1.6.
maxCommandLength => maxRequestLength
I can't understand why there is such an option. Isn't 1024 a small value for a message, usually? Since websockets are based on TCP (although you can set them as UDP in the ServerConfig), why bother trying to split the messages? The protocol will handle it anyway.
Note: I am not trying to blame the library, it's just that I'm new to networking.
Coordinator
Jan 28, 2015 at 2:36 AM
It's for the system stable and security.
If everybody send 2GB requests to the server, the server cannot handle it.
You can find IIS/ASP.NET website has the similar limitation.