socket.connect() hangs in SYN_SENT state.

Miles semanticist at gmail.com
Sun Jul 13 22:29:27 EDT 2008


On Sat, Jul 12, 2008 at 11:23 PM, bukzor <workitharder at gmail.com> wrote:
> Anyone know a general reason this might happen? Even better, a way to
> fix it?

Another reason that a socket can hang in the SYN_SENT state (besides
trying to connect to an unreachable host without getting an ICMP
destination-unreachable message in response): if the server's listen
queue is full, it will silently ignore SYN packets until there is room
in the queue.

Sorry again about the "bukzor" vs. "buzkor" thing.  I don't know
what's causing your problem (and it's probably not a DNS issue after
all) but it's more likely to be a server issue than a client one.
Maybe your client has an unusually low socket timeout for some reason,
though; does increasing it (with socket.setdefaulttimeout) help?  Mine
seems to default to about 75 seconds.

If you can't work out the root cause, but it only happens every once
in a while, you could try changing your client code to catch the
socket exception and retry a limited number of times.

-Miles



More information about the Python-list mailing list