On 01/11/2010 06:32 PM, Emmanuel Lecharny wrote:
David Rosenstrauch a écrit :
May be checking for the socket idleness every X minutes could help to
close the orphan sockets ?
I'm not clear on what you mean by this. How would I do a check like
that in MINA? Are you suggesting adding some sort of ping/pong logic?
If not, then perhaps you could point me to some sample code that
illustrates what you mean?
You can a SessionIdle event that can be used for that purpose. A session
is considered Idle if nothing happened for it during one second, and the
event is generated. I guess you can count the number of idle event you
received up to a point you consider the session dead. Also you can
consider that if all the sessions has received a Idle state, then
something is probably going wrong.
You can set the expected maximum idle time for a session using
SessionConfig.setIdleTime( IdleStatus, long) (IdleStatus is used for
READ, WRITE or BOTH)
Btw, some interesting reading :
http://mindprod.com/jgloss/socket.html#DISCONNECT
Helpful pointers. Thanks Emmanuel.
I also noticed MINA's KeepAliveFilter. Perhaps that might be some help
here too.
Thanks again,
DR