TornadoWebSocketClient doesn't support SSL #32

Closed
patrickod opened this Issue Mar 14, 2012 · 0 comments

Projects

None yet

2 participants

@patrickod
Contributor

When creating WebSockets with a WSS:// URL the TornadoWebSocketClient class fails to connect. The following is the code snippet that I'm using to test the functionality.

from ws4py.client.tornadoclient import TornadoWebSocketClient
import tornado.ioloop
c = TornadoWebSocketClient("wss://127.0.0.1:8888/")
c.connect()
tornado.ioloop.IOLoop.instance().start()

The server is a simple demo Tornado Server with SSL enabled. The error on the server side is the following

WARNING:root:SSL Error on 8: [Errno 1] _ssl.c:490: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request

The error on the client side is the following

WARNING:root:Read error on 3: [Errno 104] Connection reset by peer
ERROR:root:Uncaught exception, closing connection.
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/tornado/iostream.py", line 304, in wrapper
    callback(*args)
  File "/usr/local/lib/python2.6/dist-packages/ws4py-0.2.0-py2.6.egg/ws4py/client/tornadoclient.py", line 34, in __handshake_sent
    self.io.read_until("\r\n\r\n", self.__handshake_completed)
  File "/usr/local/lib/python2.6/dist-packages/tornado/iostream.py", line 160, in read_until
    self._check_closed()
  File "/usr/local/lib/python2.6/dist-packages/tornado/iostream.py", line 535, in _check_closed
    raise IOError("Stream is closed")
IOError: Stream is closed
ERROR:root:Exception in callback <tornado.stack_context._StackContextWrapper object at 0x99e89dc>
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/tornado/ioloop.py", line 399, in _run_callback
    callback()
  File "/usr/local/lib/python2.6/dist-packages/tornado/iostream.py", line 304, in wrapper
    callback(*args)
  File "/usr/local/lib/python2.6/dist-packages/ws4py-0.2.0-py2.6.egg/ws4py/client/tornadoclient.py", line 34, in __handshake_sent
    self.io.read_until("\r\n\r\n", self.__handshake_completed)
  File "/usr/local/lib/python2.6/dist-packages/tornado/iostream.py", line 160, in read_until
    self._check_closed()
  File "/usr/local/lib/python2.6/dist-packages/tornado/iostream.py", line 535, in _check_closed
    raise IOError("Stream is closed")
IOError: Stream is closed
^CTraceback (most recent call last):
  File "test.py", line 5, in <module>
    tornado.ioloop.IOLoop.instance().start()
  File "/usr/local/lib/python2.6/dist-packages/tornado/ioloop.py", line 282, in start
    event_pairs = self._impl.poll(poll_timeout)
KeyboardInterrupt

The problem is limited solely to the TornadoWebSocketClient class. Both of the other clients work with the server and SSL enabled. I think the problem is due to not using a tornado.iostream.SSLIOStream object in place of a tornado.iostream.IOStream object. I'll try and confirm my suspicions and post a fix if I can.

@patrickod patrickod added a commit to patrickod/WebSocket-for-Python that referenced this issue Mar 14, 2012
@patrickod patrickod Fix SSL support for TornadoWebSocketClient and add missing HandshakeE…
…rror import

Fixes #32 and #28
bd0fe5e
@Lawouach Lawouach closed this Mar 22, 2012
@mbeards mbeards pushed a commit to BotnDolly/WebSocket-for-Python that referenced this issue Jun 18, 2014
@patrickod patrickod Fix SSL support for TornadoWebSocketClient and add missing HandshakeE…
…rror import

Fixes #32 and #28
41affe9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment