-
-
Notifications
You must be signed in to change notification settings - Fork 892
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
React Native: Received data was not a string or was not recognized encoding #771
Comments
The "weird" characters are the binary encoding of Socket.IO packets. This is a standard format documented in the Socket.IO protocol. The See #716 for a similar issue. In that case the problem was addressed by connecting via websocket without passing through long-polling first. |
Connecting via websockets didn't work in this case. It looks like the binary encoding isn't being interpreted by react native. Is there a way to try a different encoding? To be more specific: Setting |
Update: when I try a node implementation of socket.io the encoding on this response is different: node:
flask-socketio:
(Note, some special characters removed because they were breaking the github comment.) React native can connect successfully to the node server, but not to the flask-socketio server. |
Yes, this client appears to have trouble with the binary representation, but that is the default. If it wants the text representation it should ask for it by sending I should note that none of this applies to WebSocket, and that is why going direct to WebSocket worked for this other person. Not sure why it does not work for you, but I'm certain you must have a different problem since the "payload" encoding is a concept that is only used in HTTP. |
Thanks so much! Adding If I had to guess, I'd say that the Thanks again! |
@davidgljay did you made it work? I set the b64 param for the GET request and it made the first request work, so I've got a socket.io session id, but GET request for protocol switch wasn't sent after that. |
Maybe you should include this in the documentation ¯_(ツ)_/¯ |
I am trying to create a connection between react native and a flask-socketio application.
I noticed that a normal browser could connect to the backend while react-native could not. Upon further investigation, calls from normal browsers included a
sid
value in the query, while calls from react-native do not.It looks like the
sid
is initially set by a GET request to flask-socketio. When I tried curling that request I got this response.�
��0{"sid":"a4ff1b37b91243c7a89a66f7159902f4","upgrades":[],"pingTimeout":60000,"pingInterval":25000}���40
Note the weird characters at the beginning and end. Also, in react native I get a somewhat cryptic error that reads: 'Received data was not a string or was not recognized encoding'.
It SEEMS like normal browsers are enable to interpret this encoding but react native is not. I'd like to get flask-socketio to send paramaters encoded in a more standard way if possible, which will hopefully address the issue in react native. I've tried changing the 'json' parser passed to Flask-socketio and this doesn't seem to help. Here's my code:
Server
I've tried using both polling and websockets on the client, neither seems to work.
The text was updated successfully, but these errors were encountered: