Reputation: 251
I have written this python code that uses socketio client module.
from socketIO_client import SocketIO
print "connecting to server"
socketIO = SocketIO('localhost', 8888, transports=['websocket'])
print "Connected"
def sendSocketId():
socketIO.emit('authenticate_python', "Python is connected")
def socketDisconnect():
socketIO.disconnect()
def doSomething(data):
print "message from ui : : ", data
socketIO.emit("msg_from_python","Message from python : : Hi! " + data)
try:
print socketIO.connected
if socketIO.connected:
sendSocketId()
socketIO.on('msg_from_node', doSomething)
socketIO.wait()
except Exception as e:
print "Exception : : ", e
socketDisconnect()
But when I connect to the server and run this file, it raises the following error:
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
connecting to server
Traceback (most recent call last):
File "C:\Users\student\app.py", line 4, in <module>
socketIO = SocketIO('localhost', 8888, transports=['websocket'])
File "C:\Python27\lib\site-packages\socketIO_client\__init__.py", line 353, in __init__
resource, hurry_interval_in_seconds, **kw)
File "C:\Python27\lib\site-packages\socketIO_client\__init__.py", line 54, in __init__
self._transport
File "C:\Python27\lib\site-packages\socketIO_client\__init__.py", line 62, in _transport
self._engineIO_session = self._get_engineIO_session()
File "C:\Python27\lib\site-packages\socketIO_client\__init__.py", line 76, in _get_engineIO_session
transport.recv_packet())
StopIteration
>>>
I have no clue about this error and also there no no proper documentations as to how should we use this socketio client module.
Upvotes: 3
Views: 3205
Reputation: 349
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
Upvotes: 0
Reputation: 251
The issue was resolved by uninstalling socket.io 2.0.0 version and installing watever version of it matches with the socketIO-client version.
Upvotes: 2