ValueError: Too many packets in payload after update to v3.10.0
See original GitHub issueI am sending a file using fixed size chunks (binary data, with size=1024 in example) using socket.io from a client to a flask_socketio server emit:
sio.emit("chunk", data=content, namespace="audio")
The audio source is just a wave file, the snippet of the generator is:
chunk_size = 1024
delay = 0.0
while data != b'':
yield data
data = wave_file.readframes(chunk_size)
time.sleep(delay)
break
Until now, the data arrived without problem. After update python-engineio to v3.10.0, if delay = 0.0, sometime server print the following error:
2019-10-24T07:47:42.708635Z [error ] post request handler error event_id=146cb3c88 host=vgonisanz-linux source=engineio.server user=vgonisanz version=dl:0.1.0
Traceback (most recent call last):
File "/home/vgonisanz/miniconda3/envs/foo3.6/lib/python3.6/site-packages/engineio/server.py", line 394, in handle_request
socket.handle_post_request(environ)
File "/home/vgonisanz/miniconda3/envs/foo3.6/lib/python3.6/site-packages/engineio/socket.py", line 123, in handle_post_request
p = payload.Payload(encoded_payload=body)
File "/home/vgonisanz/miniconda3/envs/foo3.6/lib/python3.6/site-packages/engineio/payload.py", line 15, in __init__
self.decode(encoded_payload)
File "/home/vgonisanz/miniconda3/envs/foo3.6/lib/python3.6/site-packages/engineio/payload.py", line 61, in decode
raise ValueError('Too many packets in payload')
ValueError: Too many packets in payload
This error didn’t appear before updating. Also, If I set up delay as 0.01, it don’t appear. It seems the change comes from commit c8407ae97821bb00c33a91114f425b8454f5e50e, and the issue is related with the time between requests.
- Why is this happening now?
- It is possible to continue use delay = 0 (for testing purpose I want to run my tests faster as I can)?
Thanks.
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (5 by maintainers)
Top Results From Across the Web
how to prevent valuerror: too many packets in payload in flask ...
but when i try to put my head pose function inside the socket route, the terminal show error valueError: too many packets in...
Read more >ValueError: Too many packets to unpack : r/flask - Reddit
I am using flask to run the server. But when try to send both value as a list from javascript to python it...
Read more >tests/net_test/mark_test.py - platform/system/extras
# Cause the kernel to receive packet on iif_netid. self.ReceivePacketOn(iif_netid, packet).
Read more >Packet Actions – Python and Scapy - Das Blinken Lichten
Create a new file called ping_return.py and put this code in it… 1. 2. 3. import scapy.all as scapy.
Read more >MQTT client service - proof of concept/alpha code
So, I need to manage the incoming data and add it to an existing archive record. I've got something up and running. Still...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh no, sorry I did not make myself clear on this. This was not about modifying the dependency. Just add that to your application before your create your
socketio
object. Something like this:This change that I’ve made is for security purposes. Decoding packets from payloads is somewhat expensive, and I have rarely seen payloads with lots of small packets, except when someone is trying to get the server to break. If you want to bypass this measure, you can do something like this:
You can raise the 50 to the number that you need. The value that I selected prevent high CPU usage is 16, which I thought was more than enough, but I’m open to review it and raise if a lot of people get tripped by this.