简体   繁体   中英

twisted not detecting client disconnects

Does anybody have experience with this? I have a twisted app. The clients connect to the server. I added a feature so that if a client connects to a server, but there's already a client from that IP address running, it disconnects the new client.

Once in a while, I shutdown a client computer (or VM, to be precise) without manually turning off the Python program. When I do this, once in a while but pretty often, the server does not detect any disconnect. When the computer comes back up and tries to reconnect, the server insists that there is a connection from that IP already. The only solution I've found so far is to restart the server.

Could it be strange networking things not having the disconnect go through? Twisted bug?

I'm 99% certain it's not a bug with my code to handle disconnects. My code is set up such that connectionLost is called whenever a connection is lost, including most cases of shutting down a machine, and it either logs a string saying what disconnected or throws an exception if something strange happened. Neither of these things showed up in the log.

这是一个Twisted FAQ ,尽管它实际上与Twisted没有任何关系。

Heh I can't believe I forgot all that I learned in networking class...

(2:09:44 PM) coworker: this is the expected behaviour
(2:10:15 PM) coworker: the server has no way to know if someone dies, or is just quiet
(2:10:35 PM) coworker: unless ofcourse the server has some kind of ping/keepalive message
(2:15:38 PM) claudiu: ah so if they have no communicatin
(2:15:42 PM) claudiu: there's no way to tell that a TCP connection has died
(2:15:47 PM) claudiu: i remember learning that now, yes..
(2:16:23 PM) claudiu: but if i just make the server ping the client then it'll figure out soon enough from lack of ACKs that it's dead, right?
(2:16:45 PM) coworker: right

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM