-
Notifications
You must be signed in to change notification settings - Fork 295
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
Read after write fails (Chrome DevTools Protocol server) #57
Comments
You can try this with the $ cd $GOPATH/src && mkdir -p github.com/chromedp && cd github.com/chromedp
$ git clone -b test-websocket-impls https://github.com/kenshaw/chromedp.git
$ cd $GOPATH/src/github.com/chromedp/chromedp
$ go test -v -tags gorilla
$ go test -v -tags gobwas
$ go test -v -tags nhooyr |
Thank you for the detailed report. You seem to be using the package fine. Will fix the redundant and verbose errors in #47 I'm looking into this. |
So I've gotten to the bottom of this. It looks like a bug in chrome's dp tooling to me. It cannot handle continuation frames. With gorilla/websocket and gobwas/ws, you're sending a single text frame but with this library, first the text frame is sent, then a continuation frame that finishes the frame. This is just due to the streaming style API, it doesn't know when to finish the message until you call w.Close. |
I added a c.WriteFrame method to confirm this and now the code works. If you try and use the streaming API, it fails. This is very surprising to me so I could be wrong, I'll check chrome's code. |
Known issue ChromeDevTools/devtools-protocol#24 |
Filed a bug at https://bugs.chromium.org/p/chromium/issues/detail?id=954778 Thanks again for the report @kenshaw |
Going to close this as it's not a bug in this library and I do not want to expose a function because of a bug in chrome. I'll keep that branch for now in case you want to use it. |
While the Chrome Websocket implementation may not support this, it would be prudent for this package to do so, as the other websocket implementations available do. I agree it's not a bug in this package, but if you'd like greater adoption of this package, then it needs to support existing software in the wild. I imagine other websocket implementations also have this issue. |
You make a solid point. Given I already have the code for this, I think its ok to expose a method that performs a write of a byte slice directly instead of returning a writecloser. |
See #62 |
Using this simple program:
And using it with Google Chrome's DevTools Protocol, on sending a simple message via this command:
Starting Chrome:
ken@ken-desktop:~/src/go/src/github.com/kenshaw/wstest$ google-chrome --headless --remote-debugging-port=0 --disable-gpu DevTools listening on ws://127.0.0.1:32831/devtools/browser/4f7e048b-1c84-4f05-a7fe-39fd624fb07e
And then running the simple Go test program above:
Expected output: the response from Chrome, looking something like the following:
Note: both the
gobwas/ws
andgorilla/websocket
packages work with Chrome's DevTools Protocol.I've attempted to look through the
nhooyr.io/websocket
package to determine what the cause is, but have not been able to track down what the issue is. My guess is that it's a non-standard header or some such that Chrome is returning.Perhaps I'm not using the package properly, if so, I apologize in advance, however I believe I correctly followed the examples provided in the package. Appreciate any pointers to doing this properly -- I'm also willing to help debug this issue. Thanks in advance!
The text was updated successfully, but these errors were encountered: