mrniko / netty-socketio

Socket.IO server implemented on Java. Realtime java framework
Apache License 2.0
6.82k stars 1.65k forks source link

I don't understand how to deal with timeout sessions when the server restart or shut down accidently #121

Closed otbzi closed 10 years ago

otbzi commented 10 years ago

Hi,

recently, I implemented user session management with redis, maintained a uid->session_ids map upon application level. when a client is disconnected, delete a session from this map.

but,when server restarted, there is no on-disconnect any more. So the uid->session_ids map keeps growing.

I have digged the original netty-socketio code, I guess this problem may also exist when the netty-socketio manage all sessions, I thought there may be some ZADD or ZRANGEBYSCORE etc to deal with this situation. But I haven't found any.

Sorry, I can't figure out all code clearly.

So, I want to ask , how do u deal with situation?? or could u give me some hint , how the netty-socketio code manage this situation??

Thank you very much!!!!!

otbzi commented 10 years ago

@mrniko thank you

mrniko commented 10 years ago

@otbzi i'll check onDisconnect invocation during netty-socketio shutdown

otbzi commented 10 years ago

what about the server crashed??

And normally, how do i manage the manually shutdown?? use the signal??

mrniko commented 10 years ago

Do you use redis store via client store (Redisson) or wrote your own?

otbzi commented 10 years ago

in my application,i used another redis client.

what i am trying to illustrate is that, is there a suggested way to deal with the the server restart?

if i did not invoke the stop/shutdown manually (for example, catch the signal then invoke stop()), there may be some old session remain in the redis, and will never be deleted....

it is the same when the server crashed.

Am I right about these above understanding??

mrniko commented 10 years ago

in case of server crashed library can't send any event at all, so you should care about redis state by yourself