Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid utf-8 payload #102

Closed
Oncl3joe opened this issue May 22, 2017 · 1 comment
Closed

invalid utf-8 payload #102

Oncl3joe opened this issue May 22, 2017 · 1 comment
Assignees
Labels

Comments

@Oncl3joe
Copy link

Hi Miguel,

When sending message with special chars from client to server, socket-io throw an exception :

Traceback (most recent call last):
  File "/var/www/.pyenv/versions/3.6.1/lib/python3.6/site-packages/engineio/server.py", line 279, in handle_request
    socket.handle_post_request(environ)
  File "/var/www/.pyenv/versions/3.6.1/lib/python3.6/site-packages/engineio/socket.py", line 104, in handle_post_request
    p = payload.Payload(encoded_payload=body)
  File "/var/www/.pyenv/versions/3.6.1/lib/python3.6/site-packages/engineio/payload.py", line 11, in __init__
    self.decode(encoded_payload)
  File "/var/www/.pyenv/versions/3.6.1/lib/python3.6/site-packages/engineio/payload.py", line 58, in decode
    raise ValueError('invalid payload')
ValueError: invalid payload

My javascript code :

var socket = io.connect("http://XXX:XXX", {transports:["polling"]});
socket.emit("my_event", {"data": "ééé"});

I try to modify "payload.py", and i find an exception on this line :
fixed_payload = encoded_payload.decode('utf-8').encode('raw_unicode_escape')

"encoded_payload" isn't decoded because an exception was throw. Adding encoded_payload = encoded_payload.decode('utf-8') in the except block resolve my problem, but i think it's not the best solution.

Python version : Python 3.6.1
Javascript Socket-IO version : 2.0.1

Python packages :
Flask==0.12.1
Flask-SocketIO==2.8.6
python-engineio==1.5.2
python-socketio==1.7.4
eventlet==0.21.0

@miguelgrinberg
Copy link
Owner

That line that is failing was added there to compensate for a bug in a few releases of the Socket.IO JavaScript client. They have probably changed the client in the 2.x that causes things to break in a different way. I'll have to see what I can figure out to keep this fix for the 1.x socket.io clients, while allowing the 2.x to work as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants