Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error initializing socket - transport.recv_packet() StopIteration #159

Closed
juesato opened this issue May 26, 2017 · 4 comments
Closed

Error initializing socket - transport.recv_packet() StopIteration #159

juesato opened this issue May 26, 2017 · 4 comments

Comments

@juesato
Copy link

juesato commented May 26, 2017

Hi,
I'm running a simple hello world example:

server.js

var util = require('util'),  
    http = require('http');

var app = http.createServer()

var io = require('socket.io')(app);

io.on('connection', function(socket) {
  console.log("CONNECTION!");
});

app.listen(8000);
/* server started */
console.log('> hello world running on port 8000');  

client.py

from socketIO_client import SocketIO

print "A"
socketIO = SocketIO(
    'http://localhost', 8000, verify=False)
print "HI"

The server gets to printing "CONNECTION" but the client never prints "HI". The client crashes with this traceback:

A
Traceback (most recent call last):
  File "../test.py", line 8, in <module>
    'http://localhost', 8000, verify=False)
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 353, in __init__
    resource, hurry_interval_in_seconds, **kw)
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 54, in __init__
    self._transport
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 62, in _transport
    self._engineIO_session = self._get_engineIO_session()
  File "/usr/local/lib/python2.7/dist-packages/socketIO_client/__init__.py", line 76, in _get_engineIO_session
    transport.recv_packet())
StopIteration

Do you know what could be happening here? Thanks in advance.

@juesato
Copy link
Author

juesato commented May 26, 2017

It looks like what's going on is in _get_engineIO_session (I assume this is trying to establish a connection with the server-side engineIO instance?), it's make an HTTP request to localhost:8000/socket.io where the response content is 97:0{"sid":"QK-9WUseiML1GiPQAAAj","upgrades" ["websocket"],"pingInterval":25000,"pingTimeout":60000}2:40.

This is then passed to decode_engineIO_content which is throwing an IndexError in _read_packet_length which is looking for the first 0 byte, and reading from there until a 255 byte.

I assume the issue is that the response content is incorrect, and can't be parsed correctly, but I'm not sure what the response content should look like.

@invisibleroads Would it be possible to explain what the intended purpose of this code is / how establishing the engineIO connection works? Thank you.

@juesato
Copy link
Author

juesato commented May 26, 2017

The issue was that I was using socket.io 2.0.1. Uninstalling and installing [email protected] fixed the issue.

@juesato juesato closed this as completed May 26, 2017
@lucakiebel
Copy link

I searched for a solution to this problem for days, thanks a lot!

@engbaher77
Copy link

This module socketIO-client-nexus fixes issue with compatible socket version socket.io protocol 1.x
https://pypi.org/project/socketIO-client-nexus/0.7.6/
which is not backwards compatible,
if you want to communicate using socket.io protocol 0.9 please use soketIO-client 0.5.7.2
https://pypi.org/project/socketIO-client/0.5.7.2/

Don't forget to change from import socketIO-client to socketIO-client-nexus

Hope this solve your issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants