Skip to content

Commit

Permalink
websockets: turn on autoPingInterval to expire stale connections
Browse files Browse the repository at this point in the history
With this, both clients and servers will send a PING at least once every
minute, and will drop connections that haven't seen any traffic for 10
minutes.

This should help keep NAT table entries alive, and will drop connections
that are no longer viable because their NAT entries have expired.

closes #60
  • Loading branch information
warner committed Jul 4, 2016
1 parent fc9a6f7 commit cdb5c19
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/wormhole/server/rendezvous_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,6 @@ class WebSocketRendezvousFactory(websocket.WebSocketServerFactory):
protocol = WebSocketRendezvous
def __init__(self, url, rendezvous):
websocket.WebSocketServerFactory.__init__(self, url)
self.setProtocolOptions(autoPingInterval=60, autoPingTimeout=600)
self.rendezvous = rendezvous
self.reactor = reactor # for tests to control
1 change: 1 addition & 0 deletions src/wormhole/wormhole.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ def _connect(self):
self._ws_t = self._timing.add("open websocket")
p = urlparse(self._ws_url)
f = WSFactory(self._ws_url)
f.setProtocolOptions(autoPingInterval=60, autoPingTimeout=600)
f.wormhole = self
f.d = defer.Deferred()
# TODO: if hostname="localhost", I get three factories starting
Expand Down

0 comments on commit cdb5c19

Please sign in to comment.