-
Notifications
You must be signed in to change notification settings - Fork 785
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
Client disconnects immediately after connection #365
Comments
Actually, that log message shows that the connection is closed by the browser. Could it be that |
Yes, sorry if my description was ambiguous. It is apparent that the browser closes the connection indeed. ws does not fall out of scope because I have the same browser code working when it connects to an older version of websockify ( the one you get from |
Hmm... Are you trying to send text over that socket? We dropped support for text frames in the big cleanup. Could you print the code and reason from the close in your close handler? |
code: btw, if support for text fames has been dropped then how should websockify exactly be used? I don't quite get it what it means to have dropped support for text frames. |
The WebSocket protocol is a bit of an oddball, so it has two modes of sending stuff. Either as text, or as raw data. But we need to proxy to normal TCP services which only sees data. So we naturally only use the raw data mode of WebSockets. The older code did accept incoming text messages and mixed those in with any data messages. But it would only send data messages back, so we ended up in some kind of jumble. So now we keep things sane and only accept data messages. From JavaScript that means you need to avoid sending text strings and use data types such as |
I've added 8eb5cb0 to make things a bit clearer at least. Please have a look at your JavaScript code and adjust your |
@CendioOssman thanks for this fine feedback. Turns out that I indeed send data in text-mode since the send function gets a plain JS string for an argument. I will try sending explicitly in binary mode and will get back to you if it doesn't fix the issue, but I'm sure it does 😉 |
This seems to be necessary to work with websockify 0.9.0. See novnc/websockify#365
websockify dropped support for text frames awhile back [1][2], possibly as of version 0.9.0 [3]. Attempts to send text frames to a sufficiently new websockify server result in the following error returned: Unsupported: Text frames are not supported and then the server closes the connection. This changes the client to call Webocket.send_binary() [4] instead of Websocket.send() in order to send binary data rather than text. websockify has (always?) supported receiving binary data so this should be backward compatible with older versions. Closes larsks#4 [1] novnc/websockify#365 [2] novnc/websockify@8eb5cb0 [3] novnc/websockify@8a69762 [4] https://websocket-client.readthedocs.io/en/latest/core.html#websocket._core.WebSocket.send_binary
uname -a output:
Linux Courage 4.14.74-1-MANJARO #1 SMP PREEMPT Fri Oct 5 14:16:52 UTC 2018 x86_64 GNU/Linux
I have the below code running in Chromium:
And this is what I get logged by the websockify process:
The TCP server itself gets the connection from websockify but it is immediately closed by websockify.
Same thing happens with both Firefox and Chromium. I haven't tested other browsers.
The text was updated successfully, but these errors were encountered: