Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python: socketio-client not working

Tags:

python-2.7

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.

like image 261
Shefali Avatar asked Sep 08 '26 05:09

Shefali


1 Answers

The issue was resolved by uninstalling socket.io 2.0.0 version and installing watever version of it matches with the socketIO-client version.

like image 68
Shefali Avatar answered Sep 11 '26 02:09

Shefali



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!