4

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.

2
  • Twisted framework has events and eventHandler defined at all conceptual levels - transport/ connection, protocol etc to handle a disconnect. So examining the code would help. You can post a simplified version of code that exhibits that behavior. Commented Nov 18, 2010 at 18:27
  • @pyfunc: I'll dig around the code. I suspect network issues for now, cause I made the client keep attempting to reconnect, and in some cases it was able to connect eventually (though in other cases, not). Commented Nov 18, 2010 at 19:01

2 Answers 2

5

This is a Twisted FAQ, even though it doesn't really have anything to do with Twisted specifically.

Sign up to request clarification or add additional context in comments.

Comments

2

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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.