socketIO-client icon indicating copy to clipboard operation
socketIO-client copied to clipboard

Remove unnecessary decode from received package

Open oguzhanogreden opened this issue 7 years ago • 11 comments

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.

oguzhanogreden avatar May 26 '17 11:05 oguzhanogreden

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

Nakroma avatar Jun 12 '17 19:06 Nakroma

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()

MisterWil avatar Jun 12 '17 23:06 MisterWil

This worked for me, thanks. Node 6, npm "socket.io": "^2.0.3", python 3 socketIO-client-nexus==0.7.5

lorcanoeire avatar Sep 26 '17 15:09 lorcanoeire

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?

AmazingRaise avatar Oct 23 '17 06:10 AmazingRaise

Out of interest does this fix the issue described in https://github.com/invisibleroads/socketIO-client/issues/129#issuecomment-330058318 ?

wilsonge avatar Jan 03 '18 12:01 wilsonge

@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 avatar Jan 11 '18 17:01 BenWoodford

@BenWoodford could you give me a code snippet for reproduction? I'm on python 3.6.3 and it works for me

Nakroma avatar Jan 11 '18 18:01 Nakroma

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 avatar Jan 11 '18 23:01 BenWoodford

@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.

pavoni avatar Jan 11 '18 23:01 pavoni

@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.

JasXSL avatar Feb 20 '18 21:02 JasXSL

this fix my issue connecting to cncjs. thanks!

nkruzan avatar Feb 21 '23 04:02 nkruzan