invisibleroads / invisibleroads/socketIO-client

Python 3.6: [WinError 10054] OR sslv3 alert bad record mac

Open
#163 3 comments 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
441
Forks
204
PR merge metrics
No merged PRs in 30d

Description

Hello,

I'm using python 3.6 and I'm trying to connect to 2.x socket. The lib is socketIO-client-nexus 0.7.5. Here's the code:

```
def on_response(*args):
print('response: ', args)

with SocketIO('https://streamer.cryptocompare.com', 443, LoggingNamespace) as socket:
socket.on('on_response', on_response)
socket.send("['0~Poloniex~BTC~USD']")
socket.wait(seconds=10)
```

I managed to connect to this websocket on only one occassion and I got the expected response.

As soon as I quit the program and tried reconnecting later on - I encounter one of the following two scenarios:

First - WinError 10054

```
> Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\transports.py", line 164, in send_packet
self._connection.send(packet)
File "C:\Program Files\Python36\lib\site-packages\websocket\_core.py", line 234, in send
return self.send_frame(frame)
File "C:\Program Files\Python36\lib\site-packages\websocket\_core.py", line 259, in send_frame
l = self._send(data)
File "C:\Program Files\Python36\lib\site-packages\websocket\_core.py", line 423, in _send
return send(self.sock, data)
File "C:\Program Files\Python36\lib\site-packages\websocket\_socket.py", line 116, in send
return sock.send(data)
File "C:\Program Files\Python36\lib\ssl.py", line 935, in send
return self._sslobj.write(data)
File "C:\Program Files\Python36\lib\ssl.py", line 636, in write
return self._sslobj.write(data)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\__init__.py", line 28, in wrap
return f(*args, **kw)
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\__init__.py", line 225, in _message
transport.send_packet(engineIO_packet_type, engineIO_packet_data)
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\transports.py", line 168, in send_packet
raise ConnectionError('send disconnected (%s)' % e)
socketIO_client_nexus.exceptions.ConnectionError: send disconnected ([WinError 10054] An existing connection was forcibly closed by the remote host)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\transports.py", line 164, in send_packet
self._connection.send(packet)
File "C:\Program Files\Python36\lib\site-packages\websocket\_core.py", line 234, in send
return self.send_frame(frame)
File "C:\Program Files\Python36\lib\site-packages\websocket\_core.py", line 259, in send_frame
l = self._send(data)
File "C:\Program Files\Python36\lib\site-packages\websocket\_core.py", line 423, in _send
return send(self.sock, data)
File "C:\Program Files\Python36\lib\site-packages\websocket\_socket.py", line 116, in send
return sock.send(data)
File "C:\Program Files\Python36\lib\ssl.py", line 935, in send
return self._sslobj.write(data)
File "C:\Program Files\Python36\lib\ssl.py", line 636, in write
return self._sslobj.write(data)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/[User]/PycharmProjects/[Project]/WebsocketConnection.py", line 26, in
socket.send("['0~Poloniex~BTC~USD']")
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\__init__.py", line 440, in send
self.emit('message', *args, path=path)
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\__init__.py", line 433, in emit
self._message(str(socketIO_packet_type) + socketIO_packet_data)
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\__init__.py", line 31, in wrap
return f(*args, **kw)
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\__init__.py", line 225, in _message
transport.send_packet(engineIO_packet_type, engineIO_packet_data)
File "C:\Program Files\Python36\lib\site-packages\socketIO_client_nexus\transports.py", line 168, in send_packet
raise ConnectionError('send disconnected (%s)' % e)
socketIO_client_nexus.exceptions.ConnectionError: send disconnected ([WinError 10054] An existing connection was forcibly closed by the remote host)
```
If I try relaunching the program however, it appears that I manage to connect, following warning pops up only before the connection is closed:

> WARNING:socketIO-client:streamer.cryptocompare.com:443/socket.io [connection error] recv disconnected by SSL ([SSL: SSLV3_ALERT_BAD_RECORD_MAC] sslv3 alert bad record mac (_ssl.c:2171))

Am I doing something wrong?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.