5 websocket-client module is WebSocket client for python. This provide the low level APIs for WebSocket. All APIs are the synchronous functions.
7 websocket-client supports only hybi-13.
17 This module is tested on only Python 2.7.
19 Type "python setup.py install" or "pip install websocket-client" to install.
21 This module does not depend on any other module.
26 Low Level API example::
28 from websocket import create_connection
29 ws = create_connection("ws://echo.websocket.org/")
30 print "Sending 'Hello, World'..."
31 ws.send("Hello, World")
35 print "Received '%s'" % result
39 JavaScript websocket-like API example::
45 def on_message(ws, message):
48 def on_error(ws, error):
52 print "### closed ###"
58 ws.send("Hello %d" % i)
61 print "thread terminating..."
62 thread.start_new_thread(run, ())
65 if __name__ == "__main__":
66 websocket.enableTrace(True)
67 ws = websocket.WebSocketApp("ws://echo.websocket.org/",
68 on_message = on_message,
79 wsdump.py is simple WebSocket test(debug) tool.
81 sample for echo.websocket.org::
83 $ wsdump.py ws://echo.websocket.org/
94 wsdump.py [-h] [-v [VERBOSE]] ws_url
96 WebSocket Simple Dump Tool
99 ws_url websocket url. ex. ws://echo.websocket.org/
102 -h, --help show this help message and exit
104 -v VERBOSE, --verbose VERBOSE set verbose mode. If set to 1, show opcode. If set to 2, enable to trace websocket module
108 $ wsdump.py ws://echo.websocket.org/
109 $ wsdump.py ws://echo.websocket.org/ -v
110 $ wsdump.py ws://echo.websocket.org/ -vv
117 - fixed problem to read long data.(ISSUE#12)
118 - fix buffer size boundary violation
122 - Patches: UUID4, self.keep_running, mask_key (ISSUE#11)
127 - fix Echo App Demo Throw Error: 'NoneType' object has no attribute 'opcode (ISSUE#10)
131 - delete invalid print statement.
135 - support hybi-13 protocol.
139 - fix incorrect custom header order(ISSUE#1)