-
Notifications
You must be signed in to change notification settings - Fork 556
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
Websocket client disconnecting after receiving weird opcodes #235
Comments
the opcodes are defined here: but 4 and 15 are reserved according to RFC6455. the read function has a timeout of 2sec by default. I can think of two possible problems:
how does the server side look? the git repo includes nodejs websocket server code, may this helps you to track this down a little more. |
I'm getting the same issue. It looks like the first frame it reads is always junk. If i print out the payload it will sometimes look like this: iޟ��G�W`}���2K��1{"msg":"connected","session":"xKi85FN2uLFr3Nz23"} The opcode seems to change everytime I rerun it so it looks like there is just junk being read. |
how does the server side look? |
For mine... It's does only happen when I use SSL. Normal websockets work just fine. Our server is a meteor server hosted on heroku. Plenty of other clients have been able to use SSL for us so it should be workable. |
Just a further data point, if i ignore the first 19 characters in the buffer after it connects, everything seems to work a lot better. |
After even more investigating, it looks like it might just be failing to decode the first message or something which is "{"server_id":"0"}" If i make sure it ignores that, i have no issue the rest of the way. Any idea why it would not decode the first thing sent to it? |
My issue ended up being related to this issue. esp8266/Arduino#3002 There is a merge request in that issue to the WifiClientSecure and to the TLS library. When I incorportated those changes locally it ended up fixing my issue. |
ok the problem is in the WifiClientSecure, |
Yeah oddly it never happened when I do a httpClient download over ssl which made me think it was websockets. I think you can prevent most of the problems by calling available() less often as that is the function call that screws it up. The root of the problem is every time you call available() you need to read everything in the buffer before you write anything. |
A recent update to WiFiClientSecure fixed the issues I had relating to this behavior. I was getting those constant 2 second timeouts once I switched to SSL, but this cleared that up. |
I am using the latest git version of the arduinoWebSockets lib and the WebSocketClientSSL example.
Tested with both ESP8266 Arduino core 2.4.0-rc1 and git version.
Websocket Server using the ws lib on node.js
After the ws client established the connection a first "Connected" is sent but then the client disconnects after receiving weird opCodes and reconnects again and again:
Full debug output: (opCode 8)
Example with opCode 4:
Example with opCode 15:
Am I missing something?
Thank you very much in advance! :)
The text was updated successfully, but these errors were encountered: