Session close event and total sessions

Apr 1, 2012 at 1:05 AM

Hi Kerryjian,

Thanks for your great web socket framework.

Currently, I'm using your SuperWebSocket server as a standalone console server.

There are about 500 clients looking at this server.

I've seen strange behaviour on connection between these clients and the server.

At a sudden moment, 80~90% of sessions lost their connections, based on the SessionClosed event handler.

But the total real session count was near 500.

Is there something else on the configuration or my code?

I would appreciate for your any kind tip or help as I'm struggling with this problem with commercial environment.

* the app.config

  <appSettings>    <add key="ServiceName" value="SuperWebSocket"/>    <add key="UseHeartbeat" value="true" />    <add key="HeartbeatInterval" value="20" />  </appSettings>  <socketServer>    <servers>      <server name="SuperWebSocket" serviceName="SuperWebSocket" ip="Any" port="88" mode="Async" maxConnectionNumber="3000"></server>    </servers>    <services>      <service name="SuperWebSocket" type="SuperWebSocket.WebSocketServer, SuperWebSocket" />    </services>  </socketServer>


Apr 1, 2012 at 2:47 AM

Is there anything in log files, which should be in /Logs?  

No one reported this kind problem to me before. What are the configuration below used for? Could you check whether your own heart beat works correctly?

<add key="UseHeartbeat" value="true" />    <add key="HeartbeatInterval" value="20" />

Apr 1, 2012 at 6:04 AM

Thanks Kerry,

Every clients send message to register his unique id after connection.

But, Only 50~60% players can success to register instantly, and some other players succeed the register after some delay.

Then the server start to broadcast messages (only heartbeat purpose) to each registered clients with interval. 

After few hours later, on the log, 40~50 clients lost connection within a minute.

Thanks for your help.

I could send my source code for your reference.

this is my email :

Apr 1, 2012 at 6:08 AM

It seems that there are two issues:

1) failed to resgiter

2) dropped connections unexpected

Please share me all the logs to me?

Apr 1, 2012 at 12:07 PM

Original Message of Kerry
I took a look your code, and found your locking is in low performance.
And you'd better enable SuperWebSocket's logging becuase it is very helpful for debuging.
1) LogUtil.Setup() in your code entrance;
2) /Config/log4net.config
I think you'd better design a client driven heat beat and enable clear idle session function of SuperSocket. Then, you needn't foreach all sessions.
BTW, I suggest you handle request by sub protocol ways.


Thanks Kerry,

I'm currently websocket4net based .net console clients.
But the client software were already distributed and can not be updated at this moment.
So it's hard to make client-side heart beating.
But each clients could try reconnect after closing connection.
Anyway, I have to continue server-side heart beating at this moment.
So my questions are:
1. In this case, the clear idle session function is still effective to clear some zombie sessions?
2. What is the ideal heartbeat interval to keep web socket clients sessions?
I'm using 20 seconds and I think It's too frequent.

Thanks for your kind help.