Skip to content

ping_interval doesn't change when upgrade to websocket #895

@RavioliSauce

Description

@RavioliSauce

I'll preface this by saying I'm new to websockets. So if I seem misguided, my apologies. I'm changing the ping_interval EngineIO option to 60 minutes, which works fine while long-polling. However if allow_upgrades isn't set to false, every 30 seconds, 64 bytes of data is sent, and 64 is received via NetHogs(which is what I'm using to also monitor when it's long-polling). With this connection being on a limited-data connection, this would be roughly 10.5 megabytes of usage in a month.
I have enabled the logger and EngineIO logger on both the client and the server, yet when data is sent or received, the logger doesn't show anything happening while data is being sent, and received. I've put the output of logger below, not sure that it will help. I could continue to long-poll for the time being, but just found this curious.

You can duplicate this by using the examples here: https://python-socketio.readthedocs.io/en/latest/intro.html

I let this code run for 10 minutes:

SERVER:

import eventlet
import socketio

sio = socketio.Server(ping_interval=3600, logger=True, engineio_logger=True)
app = socketio.WSGIApp(sio)

@sio.event
def connect(sid, environ):
print('connect ', sid)

@sio.event
def my_message(sid, data):
print('message ', data)

@sio.event
def disconnect(sid):
print('disconnect ', sid)

if name == 'main':
eventlet.wsgi.server(eventlet.listen(('', 5000)), app)

CLIENT:

import socketio

sio = socketio.Client(logger=True, engineio_logger=True)

@sio.event
def connect():
print('connection established')

@sio.event
def my_message(data):
print('message received with ', data)

@sio.event
def disconnect():
print('disconnected from server')

sio.connect('http://192.168.1.143:5000')

Client log output(exception at bottom is keyboardinterupt):

Attempting polling connection to http://192.168.1.143:5000/socket.io/?transport=polling&EIO=4
Polling connection accepted with {'sid': 'peZIpz0MtvHvsiQVAAAE', 'upgrades': ['websocket'], 'pingTimeout': 20000, 'pingInterval': 3600000}
Engine.IO connection established
Sending packet MESSAGE data 0{}
Attempting WebSocket upgrade to ws://192.168.1.143:5000/socket.io/?transport=websocket&EIO=4
WebSocket upgrade was successful
Received packet NOOP data
Received packet MESSAGE data 0{"sid":"oC8B1fHbBNq6vr5PAAAF"}
Namespace / is connected
connection established
Sending packet CLOSE data None
Engine.IO connection dropped
Exiting write loop task
Unexpected error decoding packet: "string index out of range", aborting
Waiting for write loop task to end
Exiting read loop task
Exception ignored in: <module 'threading' from '/usr/lib/python3.7/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 1281, in _shutdown
t.join()
File "/usr/lib/python3.7/threading.py", line 1032, in join
self._wait_for_tstate_lock()
File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
elif lock.acquire(block, timeout):
File "/home/orangepi/.local/lib/python3.7/site-packages/engineio/client.py", line 36, in signal_handler
return original_signal_handler(sig, frame)
File "/home/orangepi/.local/lib/python3.7/site-packages/socketio/client.py", line 26, in signal_handler
return original_signal_handler(sig, frame)
KeyboardInterrupt
disconnected from server

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions