-
1. Re: Can I close client connection when the client crash?
timfox Sep 15, 2010 3:02 AM (in response to shooeugenesea.tw)I don't understand the question. If the client has crashed how can it close the connection? It is no longer running.
-
2. Re: Can I close client connection when the client crash?
shooeugenesea.tw Sep 15, 2010 3:12 AM (in response to timfox)Sorry for the unclear question.
I wish there's a way to close client connection from server side.
I found that I can register an Interceptor to handle events and wish to get a event while client crashed and close the client connection.
But I can't get such event to fail the RemotingConnection, or other way to close the client connection.
Can I do things like that?
Thanks
-
3. Re: Can I close client connection when the client crash?
timfox Sep 15, 2010 3:45 AM (in response to shooeugenesea.tw)1 of 1 people found this helpfulAlso see user manual management chapter
-
4. Re: Can I close client connection when the client crash?
shooeugenesea.tw Sep 15, 2010 8:48 AM (in response to timfox)Thanks.
Finally I extends NettyAcceptorFactory and decorate the ConnectionLifeCycleListener.
When connectionException is called, then lazy get a MBeanServerConnection to call closeConnectionsForAddress.
(But cast ConnectionLifeCycleListener to RemotingServiceImpl to getConnections)
Cast interface to implmentation is a bad thing, but we need to close it immediately..
Can I do it better?
Thanks.
-
5. Re: Can I close client connection when the client crash?
timfox Sep 16, 2010 7:02 AM (in response to shooeugenesea.tw)It's not possible to always know on the server when the client has "crashed" immediately.
If the client machine just disappears or you pull out the network connection you will *not* get an exception on the server.
That''s just the way TCP works.
TCP is a reliable protocol in that it is designed to cope with temporary interruptions of network and lost packets, consequently pulling cable does not result in exceptions being thrown.
That's why we use a TTL. The only real way to be fairly sure a client has crashed is if you get no traffic from it for a certain time. Hence TTL.
In some cases you will get an exception e.g. if the client process is killed and the client machine and network is still alive - this is because when you kill the client process the OS will close it's TCP connections.
This is not true in the general case though.
-
6. Re: Can I close client connection when the client crash?
shooeugenesea.tw Sep 16, 2010 11:58 AM (in response to timfox)Thank you very much!
Your explain is very clear, let me know where the design of TTL comes from and why I can't rely on the network exception.
Maybe I need to rethink the solution or design of my requirement.
Thanks!!
-
7. Re: Can I close client connection when the client crash?
jendo Aug 19, 2011 4:49 PM (in response to timfox)How do you determine which IP address to send to HornetQServerControl.closeConnectionsForAddress? I thought perhaps I could associate certain meta data with the sessions and then determine on that, but I don't see a way to query that information on the server.
-
8. Re: Can I close client connection when the client crash?
shooeugenesea.tw Aug 24, 2011 5:02 AM (in response to jendo)Hi,
I decorate org.hornetq.spi.core.remoting.ConnectionLifeCycleListener to listen to connection exception.
Call closeConnectionsForAddress through mBean when connection exception happen.
Pass the ConnectionLifeCycleListener decorator into NettyAcceptor when NettyAcceptorFactoryImpl create it.
It's work around, but I can't find better way to close the connection immediately.
But my consumers are all in LAN with take care, so I think it's work for me.