You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to build a simple connection mechanism based on the SocketIO protocol :
A NodeMCU device (ESP8266) running the arduinoWebSockets library connects to a Flask server running the Flask-SocketIO library, providing its ID (a 24-character alphanumeric string)
If the NodeMCU's ID is part of the "authorized" IDs, the SocketIO connection sould be established normally
But if If the NodeMCU's ID is not part of the "authorized" IDs, the server should disconnect the NodeMCU and thus close the SocketIO connection
The problem :
In both cases, and despite the call to the disconnect() function in the second case, the SocketIO connection remains established. Indeed, the heartbeat mechanism triggers, and the server and the client start exchanging PINGs and PONGs at regular time intervals.
Some logs to help further understand the problem :
When the ID is authorized (nothing wrong apparently)
· Server logs
(27040) wsgi starting up on http://0.0.0.0:8080
(27040) accepted ('192.168.43.40', 53686)
[2023-04-05 16:10:57,764] qZZepzzc1pmo7PQDAAAA: Sending packet OPEN data {'sid': 'qZZepzzc1pmo7PQDAAAA', 'upgrades': ['websocket'], 'pingTimeout': 20000, 'pingInterval': 25000}
192.168.43.40 - - [05/Apr/2023 16:10:57] "GET /socket.io/?EIO=4&id=G07y2eO2HP9oy3TwvDA3oH3k&transport=polling HTTP/1.1" 200 316 0.003003
[2023-04-05 16:10:57,787] qZZepzzc1pmo7PQDAAAA: Received request to upgrade to websocket
[2023-04-05 16:10:57,805] qZZepzzc1pmo7PQDAAAA: Upgrade to websocket successful
[2023-04-05 16:10:57,807] qZZepzzc1pmo7PQDAAAA: Received packet MESSAGE data 0/
NodeMCU trying to connect with ID : G07y2eO2HP9oy3TwvDA3oH3k
Connection allowed.
[2023-04-05 16:10:57,808] qZZepzzc1pmo7PQDAAAA: Sending packet MESSAGE data 0{"sid":"Vu79-VDhIjVIu6cnAAAB"}
[2023-04-05 16:11:22,768] qZZepzzc1pmo7PQDAAAA: Sending packet PING data None
[2023-04-05 16:11:22,883] qZZepzzc1pmo7PQDAAAA: Received packet PONG data
[2023-04-05 16:11:47,883] qZZepzzc1pmo7PQDAAAA: Sending packet PING data None
[2023-04-05 16:11:47,972] qZZepzzc1pmo7PQDAAAA: Received packet PONG data
[2023-04-05 16:12:12,994] qZZepzzc1pmo7PQDAAAA: Sending packet PING data None
[2023-04-05 16:12:13,057] qZZepzzc1pmo7PQDAAAA: Received packet PONG data
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What am I trying to do ?
I am trying to build a simple connection mechanism based on the SocketIO protocol :
The problem :
In both cases, and despite the call to the
disconnect()
function in the second case, the SocketIO connection remains established. Indeed, the heartbeat mechanism triggers, and the server and the client start exchanging PINGs and PONGs at regular time intervals.Some logs to help further understand the problem :
When the ID is authorized (nothing wrong apparently)
· Server logs
· NodeMCU logs
When the ID is not authorized (something wrong)
· Server logs
· NodeMCU logs
The minimal tested code:
Here is the minimal Flask webapp code :
and here is the minimal NodeMCU code :
Thank you very much for your help !
Beta Was this translation helpful? Give feedback.
All reactions