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

Message invalid protocol Selected 400 - Firefox #390

Closed
imatrycode opened this issue Apr 8, 2019 · 3 comments
Closed

Message invalid protocol Selected 400 - Firefox #390

imatrycode opened this issue Apr 8, 2019 · 3 comments

Comments

@imatrycode
Copy link

imatrycode commented Apr 8, 2019

I've been having major issues serving websockify and for whatever reason I cannot get it working via Firefox.
This works fine in Chrome and IE and edge just not firefox, I keep getting the bellow error, I am using tokens and SSL, I have tried without SSL and can confirm all ports are open. It seems Firefox is having issues.

this is the error I get from a debugged connection:

root@ubuntu:~/test/websockify# ./run  --cert=/etc/apache2/ssl/piggybank.cloud/piggybank.cloud-certificate.crt --key=/etc/apache2/ssl/piggybank.cloud/piggybank.cloud.key 8080 --token-plugin TokenFile --token-source /tokens/tokens.config.d/ --log log.txt -v --ssl-target --web=/var/www/html/mycloud/vnc
WebSocket server settings:
  - Listen on :8080
  - Web server. Web root: /var/www/html/mycloud/vnc
  - SSL/TLS support
  - proxying from :8080 to targets generated by TokenFile (using SSL)
213.210.32.5: new handler Process
host5.gci.network - - [08/Apr/2019 22:26:36] code 400, message Invalid protocol selected
host5.gci.network - - [08/Apr/2019 22:26:36] "GET /?token=66b7ac55af53352584e353f4589e950a3bb987ca9f1020caa028208b37f411f936d5154530e98006bcab3c1bf214081304570bb7f3af9b1ff25e797c8cb0c475 HTTP/1.1" 400 -
Ignoring interrupted syscall
^CIn exit
Closing socket listening at :8080
root@ubuntu:~/test/websockify# ./run  --cert=/etc/apache2/ssl/piggybank.cloud/piggybank.cloud-certificate.crt --key=/etc/apache2/ssl/piggybank.cloud/piggybank.cloud.key 8080 --token-plugin TokenFile --token-source /tokens/tokens.config.d/ --log log.txt -v --ssl-target --web=/var/www/html/mycloud/vnc
@CendioOssman
Copy link
Member

That error code means that the client requested a specific WebSocket sub-protocol that we do not know about. The standard code will only proxy clients that don't ask for anything specific.

What is the client in this case? It's very odd that it only affects Firefox. All browsers should have the same behaviour for sub-protocols.

@samhed
Copy link
Member

samhed commented Sep 26, 2019

No response

@samhed samhed closed this as completed Sep 26, 2019
@candlerb
Copy link

FYI, I am seeing the same error, with Chrome 85 (macOS) and SSHy over a plain HTTP connection.

For me, the problem is that SSHy is asking for "base64" as the websocket protocol, but websockify only supports "binary".

Here is the exchange as captured by tcpdump:

<-- GET /?token=noc HTTP/1.1
Host: 100.64.0.1:5999
Connection: Upgrade
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36
Upgrade: websocket
Origin: http://100.64.0.1
Sec-WebSocket-Version: 13
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en;q=0.9,en-US;q=0.8
Cookie: sessionid-GOL6H=XXXX; CSRF-Token-GOL6H=XXXX; _xsrf=XXXX
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Sec-WebSocket-Protocol: base64

--> HTTP/1.1 400 Invalid protocol selected
Server: WebSockify Python/3.6.9
Date: Fri, 18 Sep 2020 11:05:42 GMT
Connection: close
Content-Type: text/html;charset=utf-8
Content-Length: 474

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: 400</p>
        <p>Message: Invalid protocol selected.</p>
        <p>Error code explanation: 400 - Bad request syntax or unsupported method.</p>
    </body>
</html>

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

No branches or pull requests

4 participants