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

failing WebSocket opening handshake #508

Closed
balinttahi opened this issue Jun 3, 2020 · 18 comments
Closed

failing WebSocket opening handshake #508

balinttahi opened this issue Jun 3, 2020 · 18 comments
Labels

Comments

@balinttahi
Copy link

Hi, I am trying to use our NACHI ROS Driver (FlexGui 2.4) with rosbridge. It was working fine with ROS Kinetic (and also older ones), now we moved to ROS Melodic and we are not able to connect anymore. The error message is the following:

failing WebSocket opening handshake ('missing port in HTTP Host header '192.168.212.141' and server runs on non-standard port 9090 (wss = False)')
2020-06-02 15:12:57+0200 [-] dropping connection to peer tcp4:192.168.212.138:1050 with abort=False: missing port in HTTP Host header '192.168.212.141' and server runs on non-standard port 9090 (wss = False)

We are running rosbridge on the default 9090 port, WSS is false.

Specifications

  • ROS Version (echo $ROS_DISTRO): melodic
  • OS Version (grep DISTRIB_CODENAME /etc/lsb-release): bionic
  • Rosbridge Version (roscat rosbridge_server package.xml | grep '<version>'): 0.11.4
  • Twisted Version (python -c 'import twisted; print twisted.version'): 17.9.0
@gavanderhoorn
Copy link

Is this a duplicate of #497 (which is a duplicate of #488)?

@balinttahi
Copy link
Author

Is this a duplicate of #497 (which is a duplicate of #488)?

We are not using jrosbridge, so in this sense, it is not. The error is the same.

@mvollrath
Copy link
Contributor

This should work by default starting in 0.11.7.

@gavanderhoorn
Copy link

According to status_page/ros_melodic_default.html?q=rosbridge Melodic currently is at 0.11.8.

@balinttahi: would you have pending updates?

@balinttahi
Copy link
Author

rosbridge_version

Same issue with 0.11.8

@balinttahi
Copy link
Author

balinttahi commented Jun 3, 2020

This should work by default starting in 0.11.7.

I tried many versions from github to solve the problem, starting from 0.11.4 but I had this problem in all of them.

Now I installed it with
sudo apt-get install ros-melodic-rosbridge-server
which is the latest, 0.11.8, but I still getting the same issue.

@mvollrath
Copy link
Contributor

I can try to reproduce this if you can point me at the repo for NACHI ROS Driver or submit code for an isolated example client.

Otherwise, here is a brief code review:

Here is where the error comes from. You can see that if externalPort is None (which is now the default value), it skips this check.

Here is where rosbridge gets the param (defaulting to None if it is not a base10 integer) and here is where that value is sent to the factory.

@mvollrath
Copy link
Contributor

mvollrath commented Jun 3, 2020

The client you are using may not be correctly implementing the Host header according to RFC2616:

A "host" without any trailing port information implies the default port for the service requested (e.g., "80" for an HTTP URL).

The only valid case for not specifying the port is a proxy listening on port 80. In this case configuring external_port parameter to 80 would fix this, but that check should not even be happening if you are running the correct version of rosbridge.

You might try clearing your ROS params, a bad value may still be sitting in external_port.

@balinttahi
Copy link
Author

5 minutes ago, I almost said it is working.

FlexGui 2.4 (NACHI Driver) can connect now to rosbridge, if the websocket_external_port is 80.
But roslib.js can't, because of the following error:

2020-06-03 23:08:31+0200 [-] failing WebSocket opening handshake ('port 9090 in HTTP Host header 'localhost:9090' does not match server listening port 80') 2020-06-03 23:08:31+0200 [-] dropping connection to peer tcp4:127.0.0.1:48994 with abort=False: port 9090 in HTTP Host header 'localhost:9090' does not match server listening port 80

Neither a C# code (using simple websocket client):
2020-06-03 23:09:26+0200 [-] failing WebSocket opening handshake ('port 9090 in HTTP Host header '192.168.212.141:9090' does not match server listening port 80') 2020-06-03 23:09:26+0200 [-] dropping connection to peer tcp4:192.168.212.120:55825 with abort=False: port 9090 in HTTP Host header '192.168.212.141:9090' does not match server listening port 80

So this "solution" kills everything else (or I am missing something). Ofc. the listening port can't be 80, because for that, I need to run rosbridge as root.

@balinttahi
Copy link
Author

If I run 2 rosbridge in 2 different namespace (1 in root, 1 in lets say ... "legacy"). The legacy has the external_port = 80, the one in the root is a totally default rosbridge, then everything works fine ... ofc I am eating more resources than I should and this is just a brute force workaround ... but at least working.

If you have a much better solution, where:

  • I don't need to run 2 bridges
  • I don't need to update the cpp code
  • I need only to modify the settings of the rosbridge_server
    I am super open to use that...

Thanks!

@mvollrath
Copy link
Contributor

I recommend fixing the request headers. If you have a solution for rosbridge, your PR is welcome.

@PapeCoding
Copy link

PapeCoding commented Aug 10, 2020

I am getting the exact same error message like @balinttahi.
As suggested I tried out the newest version 0.11.9 in melodic. Also clearing the external port number. Still, not working. I would be very thankful, if there would be another solution than changing the request, even if this would be the correct solution. In my case, I can't easily change the Unreal Engines source code, which apparently doesn't comply with RFC2616 in this case.

By looking at the Factory code, I noticed, that the clearing of the external port parameter cannot work, since, if it it not defined, they are parsing the port out of the URL that ROSBridge gives it here

@PapeCoding
Copy link

PapeCoding commented Aug 11, 2020

This should actually be fixed in newer versions of autobahn crossbario/autobahn-python@80fe02d . Unfortunately these require python3 which might break other things.

Update:
Tried it out on ROS Noetic and updated Autobahn manually. Works perfectly.
As a workaround, it worked for me to actually set the external port to 80. Then my client could connect easily.

@rubenanapu
Copy link

I had the same problem and solved it with the websocket_external_port arg.

The port 40000 in the host was mapped to 9090 in the container. Below is the full command I used:

roslaunch rosbridge_server rosbridge_websocket.launch _port:=9090 websocket_external_port:=40000 --screen

@gonzalocasas
Copy link
Contributor

Tried it out on ROS Noetic and updated Autobahn manually. Works perfectly.

Works! Thanks!

@cgdsss
Copy link

cgdsss commented Oct 12, 2021

I had the same problem and solved it with the websocket_external_port arg.

The port 40000 in the host was mapped to 9090 in the container. Below is the full command I used:

roslaunch rosbridge_server rosbridge_websocket.launch _port:=9090 websocket_external_port:=40000 --screen

roslaunch rosbridge_server rosbridge_websocket.launch port:=9090 websocket_external_port:=40000 --screen
Works! Thanks!

@ussefdesouky
Copy link

Worked when the websocket_external_port:=80, one week trying to figure it out.
roslaunch rosbridge_server rosbridge_websocket.launch _port:=9090 websocket_external_port:=80 --screen

@github-actions
Copy link

This issue has been marked as stale because there has been no activity in the past 6 months. Please add a comment to keep it open.

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

8 participants