简体   繁体   中英

Unexpected response code: 426 with PhanthomJS Websocket client/ROSLIB

I'm trying to use PhanthomJS (1.9.7) to setup batch test script to drive our robotics software over our Websocket server (RosBridge which is implemented on top of Tornado).

We use ROSLIBJS which is a JS library that uses the standard HTML5 WebSocket API to interact with the server. I would have preferred to use NodeJS instead of PhantomJS, but there are dependencies in the ROSLIBJS that requires browser DOM structures to be available. Someone ported ROSLIBJS for NodeJS. I got it running, but there were critical bugs that prevented it from being usable. Hence, I need PhantomJS.

According to this link, there is some incompatibility with the Websocket protocol. Unexpected response code 426

Is that a known issue. If so, when would PhantomJS be fixed for this to work? Can I patch PhantomJS myself easily?

Http 426 may mean that you are trying to connect with an unsupported websocket protocol version. Check if the response has the http header "sec-websocket-version" with a list of supported versions.

Which version is your client using?

Also, if you are connecting through a proxy, the proxy may remove the "upgrade" header from the request since it is marked as "connection" header. Switch to WSS:// to prevent that.

Funny enough, I was looking at writing integration tests for roslibjs and ran across this question. I'll try phantomjs-2.0 ( https://github.com/Vitallium/phantomjs-qt5 ) and real chrome via chromedriver. I'll most like PR the results against roslibjs.

An alternative option would be to write another bridge that uses socket.io for client communication to achieve maximum portability.

See this PR: https://github.com/RobotWebTools/roslibjs/pull/83 . It uses chrome to run tests. Alternatively you can allow rosbridge to accept draft76 websockets by changing https://github.com/RobotWebTools/rosbridge_suite/blob/develop/rosbridge_server/src/tornado/websocket.py#L186 to return True;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM