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
Hybi13 support (was: Webkit Remote Debugging WebSocket client connections fail) #39
Comments
Thanks for the report! Would it be possible to include the code for the server as well? |
Unfortunately I have no idea how the (websocket) server works. It's built into Chrome. The API itself is a JSON-RPC API, so the response is supposed to be e.g. {"result":{},"id":1}. The issue is that the websockets library (supposedly) sends the message in such a way that Chrome feels the connection should be terminated. I tried to dig around for it in the source, but that repository is monstrous. It's supposed to be based on the Webkit Remote Debugging protocol: https://www.webkit.org/blog/1875/announcing-remote-debugging-protocol-v1-0/ I made a JavaScript client which connects to the same URL, and works fine: -- test.js
-- test.html
(Change WS URL to that reflected in localhost:9222/json for an active tab) Result (from JS console): Connecting test.js:2 Since this worked in Chrome, but not Firefox, I was wondering if it might be related to support for the webkit-deflate-frame extension, but as far as I can tell, the extension is not negotiated in the upgrade request/response. (Perhaps it expects only Hybi13?) I wrote this Python test using https://pypi.python.org/pypi/websocket-client/0.7.0 (which supports Hybi13):
Output: Received: {"result":{},"id":1} So, it seems to me the most likely cause is either that it expects a more recent Hybi, or that the hs websockets library communicates the path differently somehow? |
After a little investigation, I've become fairly convinced that the issue is indeed just that hs-websockets doesn't speak Hybi13. I also noticed that this version has become the default/only supported version in many other WS libraries. For convenience, here are the differences: https://tools.ietf.org/rfcdiff?url1=draft-ietf-hybi-thewebsocketprotocol-10.txt&url2=draft-ietf-hybi-thewebsocketprotocol-13.txt (not to worry, most are just rearrangements/rephrasing.) I might open a pull request later, but at the moment I am unfortunately not very savvy with WS internals (lib and spec.) |
Is the fact that something like this just fails related to this issue?
|
At some point between version 0.7.2.1 and 0.7.4.0, this was solved on my end. I can now successfully connect to and communicate with the Chrome remote debugger, which (I assume) uses Hybi13 or higher. If you didn't address this, presumably something changed on the Chrome side. Apologies again for being so vague. |
Looking at a few of the recent commits, I think Chrome might have disconnected me because the frames weren't masked. It works when I use sendTextData (after the masking change), not with sendBinaryData. |
Doesn't work for me :( 2013/7/16 Patrick Mylund Nielsen notifications@github.com
|
This is fixed in the latest verion, |
I just tried to connect to the mtgox websocket api with
running it yields:
|
I can confirm the connection to Chrome (sending text data) still works as expected in 0.8. |
@fhaust If I run the following JavaScript code in Chromium:
It fails with the same 403 error. I'm quite sure Chromium's WebSockets implementation is not broken, so something else might be off. Since 403 deals with authorization, possibly you are required to set some Cookie or connect over SSH? |
According to the API (https://en.bitcoin.it/wiki/MtGox/API/Streaming) authorization is only required when accessing private features. There is a way to connect via SSL ... but afaik websockets doesn't support SSL/TLS, does it? |
It doesn't support it directly but with some boilerplate setting up an SSL connection is not that hard, see e.g. this example: https://gist.github.com/jaspervdj/7198388 I'll probably add this to the WebSockets library at some point, however I don't want to directly depend upon |
Run Chrome with remote debugging: google-chrome --remote-debugging-port=9222
Try to connect to one of the URLs from http://localhost:9222/json, e.g. ws://127.0.0.1:9222/devtools/page/12_1. After sending/receiving a message, the connection is closed/broken pipe, regardless of whether you use ByteStrings/BinaryData/BinaryProtocol or Text/TextData/TextProtocol.
Example message: {"method":"Inspector.enable","id":1}
The text was updated successfully, but these errors were encountered: