My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
TestingYourWebSocketImplementation  
Updated Oct 18, 2011 by tyosh...@chromium.org

Testing your server implementation using echo_client.py in pywebsocket

For example, to connect to ws://example.com:12345/test using HyBi 13 version protocol, and send three text frames "Hello", "foo", "bar" to it, run this:

svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
cd pywebsocket-read-only/src
PYTHONPATH=. python example/echo_client.py -s example.com -p 12345 -r /test \
  -m Hello,foo,bar --protocol_version=hybi13 --origin=http://example.com:12345/ \
  --log-level=debug

Testing your client implementation using standalone.py in pywebsocket

To launch pywebsocket standalone server on port 12345 with echo back service on /echo with HyBi 13, HyBi 08, HyBi 00 and Hixie 75 protocol support, run this:

svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
cd pywebsocket-read-only/src
PYTHONPATH=. python mod_pywebsocket/standalone.py -p 12345 --allow-draft75 -d example --log-level debug

Open http://localhost:12345/console.html using your client and check if the messages you send are echoed back.

Comment by zor...@gmail.com, May 4, 2011

how can to handle disconnect from device without any messages, ex. lost internet connection? Any exception on recvd or sent methods or others?

Comment by project member tyosh...@chromium.org, May 12, 2011

First, see this thread. http://groups.google.com/group/pywebsocket/browse_thread/thread/d341032b6e00cb1 To handle the case that the other peer disappears silently, you need to implement ping/pong and timeout logic by yourself. As latest WebSocket? protocol supports ping/pong in itself, pywebsocket may provide some automatic keep alive, but not yet implemented.

Comment by Kaa...@gmail.com, Nov 15, 2011

it says me : ImportError?: No module named mod_pywebsocket

Comment by project member tyosh...@chromium.org, Apr 3, 2012

Please make sure to prepend "PYTHONPATH=." before the command as instructed above to add mod_pywebsocket directory to Python's search path.

Comment by luke.sta...@gmail.com, May 26 (47 hours ago)

This is a convoluted example. It should be more like: wget something python some.py google-chrome example.html


Sign in to add a comment
Powered by Google Project Hosting