danpaquin / coinbasepro-python

The unofficial Python client for the Coinbase Pro API
MIT License
1.82k stars 740 forks source link

Sockets stopped connecting with SNI-related error (python2.7) #424

Open Tectract opened 3 years ago

Tectract commented 3 years ago

Running the websocket client test code from the readme, I'm getting a SNI-related connection error now. It seems that Coinbase has enabled SNI on their servers and python2.7 clients may not be able to connect anymore. This problem is REALLY hard to troubleshoot for python2.7.6 users! I'm sort of locked to an OS that runs on python2.7 for the moment so I need to get around this somehow.

How can I write a simple tool that will run under python3 here, just connect to a websocket print out the lines to the command-line? Can anyone help?

For reference the error I'm seeing under python2.7.6 now is this:

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 763, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/myusername/.local/lib/python2.7/site-packages/cbpro/websocket_client.py", line 40, in _go
    self._connect()
  File "/home/myusername/.local/lib/python2.7/site-packages/cbpro/websocket_client.py", line 72, in _connect
    self.ws = create_connection(self.url)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 487, in create_connection
    websock.connect(url, **options)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_core.py", line 211, in connect
    options.pop('socket', None))
  File "/usr/local/lib/python2.7/dist-packages/websocket/_http.py", line 77, in connect
    sock = _ssl_socket(sock, options.sslopt, hostname)
  File "/usr/local/lib/python2.7/dist-packages/websocket/_http.py", line 182, in _ssl_socket
    sock = ssl.wrap_socket(sock, **sslopt)
  File "/usr/lib/python2.7/ssl.py", line 487, in wrap_socket
    ciphers=ciphers)
  File "/usr/lib/python2.7/ssl.py", line 243, in __init__
    self.do_handshake()
  File "/usr/lib/python2.7/ssl.py", line 405, in do_handshake
    self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:510: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
Tectract commented 3 years ago

relevant issue in ws4py implementation of websockets, which I also debugged for ws-feed.pro.coinbase.com websocket connection.