pychrome
pychrome copied to clipboard
WebSocketBadStatusException raised when connecting to webSocketDebuggerUrl in Chrome 108+
When using PyChrome to connect to a tab's "webSocketDebuggerUrl" in Chrome 108 or newer, the following error is raised: "websocket._exceptions.WebSocketBadStatusException: Handshake status 403 Forbidden".
Seems to be related to Chrome checking the Origin of the incoming request. The recommended fix seems to be to suppress the header entirely: https://bugs.chromium.org/p/chromium/issues/detail?id=1422444#c5
I added an extra kwarg suppress_origin=True
and that fixed the issue.
https://github.com/fate0/pychrome/blob/c6c755b9964eead9a84dd57e84f53eb9981b26ac/pychrome/tab.py#L208
I tried it and that worked! Thanks and good job! 💖
suppress_origin=True
This fix worked. Can you raise the PR for this?
@sc231997 feel free to include it in #62
@sc231997 feel free to include it in #62
Done!
version(0.2.4) I'm using has this suppress_origin=True
and still not working
independent of any port I use.
chrome version: 117.0.5938.63
still not working
start chrome with one of
--remote-allow-origins=http://localhost:5222
--remote-allow-origins=*
chrome will print this to stderr
[ERROR:devtools_http_handler.cc(768)] Rejected an incoming WebSocket connection from the http://localhost:5222 origin. Use the command line flag --remote-allow-origins=http://localhost:5222 to allow connections from this origin or --remote-allow-origins=* to allow all origins.
see also
- https://github.com/MasterDevs/ChromeDevTools/issues/52#issuecomment-1500857987
- https://github.com/marty90/PyChromeDevTools/issues/28#issuecomment-1491529548