tl;dr Using this library, Raspberry Pi's can handle websocket transport as servers, but always resort to polling when clients.
This setup involves raspberry pi's running as clients and one as a server. When a pi is told to act as the server, it can handle websocket connections from socketio.Client running on my pc and macbook. But when I assign a RPI to be a client, it uses polling, and when I force the transport to websocket, the client hangs and then exits. I have logging on, but it's not verbose.
Using python 3.5, and running the server with eventlet.
Logs below probably don't help much? I'm really just opening this up to see if anyone has some knowledge as to why Raspbian will run as a websocket server, but doesn't want to use websockets running the client lib, and my other os's will.
SERVER SIDE:
connect
192.168.0.4 - - [20/Feb/2019 13:19:09] "GET /socket.io/?transport=polling&EIO=3&t=1550697549.7844124 HTTP/1.1" 200 381 0.021168
192.168.0.4 - - [20/Feb/2019 13:19:10] "POST /socket.io/?transport=polling&EIO=3&sid=9a9aacaaac2b44afb15c090f193152ae HTTP/1.1" 200 199 0.006060
(24902) accepted ('192.168.0.4', 36078)
CLIENT SIDE:
Engine.IO connection established
Namespace / is connected
connection established
*just to clarify, I have run pi clients for an hour and they never switch from polling. And when transport is forced, the pi clients just give up if they can't use polling.
Also I have had a raspberry pi act as server to itself as a client, and its still resorts to polling itself.
Okay, update. On macos I was running the client in 2.7. Running it on 3.5 I get the same issue as on the pi.
Inversely, I tried running a client in 2.7 on the Pi, but I still get polling. Makes me think theres a dependency I'm missing? If requests isnt already on the machine, its has me install that, but might there be something else?
Did you install the websocket client on your Pi? Try pip install "python-socketio[client]" or pip install "python-socketio[async-client]" to get the required dependencies into your environment.
Yes, but ran that again with both python 2.7 and 3.5 for posterity. Still polling or nothing from pi's.
This is what installs:
python-engineio 3.4.3
python-socketio 3.1.2
six 1.12.0
Okay, I need to review how I have the dependencies set up then. Try installing the required dependencies manually:
pip install requests websocket-client
nailed it. thank you!
Most helpful comment
nailed it. thank you!