Skip to content Skip to sidebar Skip to footer

Twisted Unexpected Connection Lost

I wrote a TCP server using Python Twisted to send/receive binary data from clients. When a client close their application or calls the abortConnection method, I get the connection

Solution 1:

Enabling TCP keepalive on your socket should fix this.

By default this is disabled and thus if the connection is broken client and server will never find out the connection is dead and simply assume there is no packets being send. A keepalive will send a 'heartbeat' each x interval to see if the connection is still alive.

Read more and check how to do it here: How to use TCP Keepalive with Endpoints in Twisted?

Solution 2:

The only way to support a cross-platform unexpected disconnection (unplug) is to implement a application-level ping message to ping clients in a specific interval.

Post a Comment for "Twisted Unexpected Connection Lost"