Formatting messages to send to socket.io node.js server from python client Formatting messages to send to socket.io node.js server from python client python python

Formatting messages to send to socket.io node.js server from python client


I wrapped rod's research into a barebones socket.io client library.

pip install -U socketIO-clientpython    from socketIO_client import SocketIO    with SocketIO('localhost', 8000) as socketIO:        socketIO.emit('aaa')        socketIO.wait(seconds=1)


Resolved. I needed to use double quotes. Single quotes are not valid JSON. Woops.

ws.send("5:1::{'name':'newimg', 'args':'bla'}")

Becomes:

ws.send('5:1::{"name":"newimg", "args":"bla"}')