socketIO-client
socketIO-client copied to clipboard
Remove unnecessary decode from received package
Fixes #155.
See here for why this works. Ultimately, my commit can lead to a bit more simplification of the code. Thought I'd leave that for @invisibleroads seeing that there is a 8.0.0 branch.
Since this package doesn't seem to be worked on very much, I went ahead and forked it and implemented your fixes. For anyone interested working with 2.x you can use it with pip install socketIO-client-nexus
while we wait for 8.0 or another package to add 2.x support.
https://github.com/nexus-devs/socketIO-client
This pull still has an issue with unicode handling in the _read_packet_text def in parsers.py. The last two lines need to pull the packet_text using the decoded contents and then re-encode the packet_text.
packet_text = content.decode()[content_index:content_index + packet_length]
return content_index + packet_length, packet_text.encode()
This worked for me, thanks. Node 6, npm "socket.io": "^2.0.3"
, python 3 socketIO-client-nexus==0.7.5
socketio/socket.io#2833 socket.io(version 2.0.x ):Merge Engine.IO and Socket.IO handshake packets; so read the packet error.It means do as Socket.IO do?
Out of interest does this fix the issue described in https://github.com/invisibleroads/socketIO-client/issues/129#issuecomment-330058318 ?
@Nakroma I tried using the nexus package but was still getting the StopIteration
error but only on Python >=3.5
I guess this issue is still up in the air?
@BenWoodford could you give me a code snippet for reproduction? I'm on python 3.6.3
and it works for me
Perhaps it’s a different issue with the same symptom then... I’m tinkering with the pyloopenergy library and that’s what’s throwing a StopIteration (as per this https://github.com/home-assistant/home-assistant/issues/8137#issuecomment-356997967)
Hmm
@BenWoodford @Nakroma In pyloopenergy
we're using version 0.5.6 because the server we're talking to is socket.IO version 0.9
Don't know if the the same issue - and if so whether it's practical to port it back.
@Nakroma I believe there's an issue with your fork where the connect/reconnect events are never raised. I added some further debugging and it seems like I'm only receiving packets of type 3 & 4
Edit: disconnect is actually being raised, just not connect/reconnect.
this fix my issue connecting to cncjs. thanks!