File: README.md

package info (click to toggle)
python-autobahn 23.1.2%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,424 kB
  • sloc: python: 38,620; javascript: 2,705; makefile: 899; ansic: 373; sh: 63
file content (20 lines) | stat: -rw-r--r-- 849 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Auto Reconnecting WebSocket Client

This example demonstrates a WebSocket client that automatically retries connecting when the server connection is lost (or could not be established in the first place).

The reconnection schedule is doing proper exponential backoff. Please see Twisted documentation for [ReconnectingClientFactory](http://twistedmatrix.com/documents/current/api/twisted.internet.protocol.ReconnectingClientFactory.html)

## Running

Start the server in a first terminal:

	python server.py

Now start the client in a second terminal:

	python client.py

Then stop the server. The client looses the connection. Restart the server. The client will automatically reconnect to the server.

You can also start the client before starting the server. The client will connect when the server comes up (upon next reconnection schedule).