Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Threaded WebSocket client always exits randomly #78

Closed
muellermartin opened this issue Feb 18, 2013 · 6 comments
Closed

Threaded WebSocket client always exits randomly #78

muellermartin opened this issue Feb 18, 2013 · 6 comments

Comments

@muellermartin
Copy link

I tried to implement a simple WebSocket client for a CherryPy server which should work like the droid_sensor.py and its server under "example", but if I try to run the client it always stops randomly in the send loop and exits with a random WebSocket error code (one of 1002, 1006 and 1007).

This is the server log from the CherryPy server:

127.0.0.1 - - [18/Feb/2013:02:49:54] "GET /ws HTTP/1.1" 101 - "" ""
[18/Feb/2013:02:49:54]  Managing WebSocket connection from 127.0.0.1:55280
[18/Feb/2013:02:49:54]  Managing WebSocket connection from 127.0.0.1:55280
Exception in thread WebSocket client at 127.0.0.1:55280:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 505, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/Users/martin/Desktop/test/ENV/lib/python2.7/site-packages/ws4py/websocket.py", line 246, in run
    self._cleanup()
  File "/Users/martin/Desktop/test/ENV/lib/python2.7/site-packages/ws4py/websocket.py", line 197, in _cleanup
    self.stream._cleanup()
AttributeError: 'NoneType' object has no attribute '_cleanup'

[18/Feb/2013:02:49:55]  Removing WebSocket connection 127.0.0.1:55280
[18/Feb/2013:02:49:55]  Removing WebSocket connection 127.0.0.1:55280

This is my client (very similar to example/droid_sensor.py):
https://gist.github.com/muellermartin/4974648

and this is the server:
https://gist.github.com/muellermartin/4974657

P.S.: The host in line https://github.com/Lawouach/WebSocket-for-Python/blob/master/example/droid_sensor.py#L98 seems to be wrong (script crashes with ValueError: Invalid scheme: http) - shouldn't this be "ws://127.0.0.1:9000/ws"?

@Lawouach
Copy link
Owner

Would you mind telling me which ws4py version you're running please?

As for the droid example, I must admit that's one piece I haven't maintained well so if it's failing I'm not entirely surprised.

@muellermartin
Copy link
Author

Of course, here are the versions I use:
ws4py 0.2.4
CherryPy 3.2.2
Python 2.7.2

@Lawouach
Copy link
Owner

Okay. May I ask you if you could try with the latest HEAD (0.3.0-beta) please? I've made some modifications that could help (or not ;)).

@muellermartin
Copy link
Author

That was a good idea: It seems to work now as expected!

Edit: Despite the fact that the client is working, the server displays this error immediately after the client is started:

127.0.0.1 - - [18/Feb/2013:11:29:52] "GET /ws HTTP/1.1" 101 - "" ""
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "build/bdist.macosx-10.8-intel/egg/ws4py/manager.py", line 255, in run
    if not ws.once():
  File "build/bdist.macosx-10.8-intel/egg/ws4py/websocket.py", line 295, in once
    if not process(b):
  File "build/bdist.macosx-10.8-intel/egg/ws4py/websocket.py", line 368, in process
    s.message.data = None
AttributeError: 'NoneType' object has no attribute 'data'

@Lawouach
Copy link
Owner

Damned! :)

I'll probably need to test it out but that won't be before this evening at best. Sorry.

@muellermartin
Copy link
Author

I mean the client is running and the server keeps running too, except this exception appears in the server log as soon the client connects, so take your time ;) Thanks anyway sofar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants