chrome-devtools-java-client
chrome-devtools-java-client copied to clipboard
Support Chrome 111+
Chrome 111 was just released which breaks this library.
HTTP PUT must now be used instead of GET for json/new. Should work with older Chrome versions too.
Note that the origin for DevTools Websocket connections must now be specified explicitly, e.g. using --remote-allow-origins=* (see https://groups.google.com/g/chromedriver-users/c/xL5-13_qGaA).
ChromeArguments.defaults(true)
// …
.additionalArguments("remote-allow-origins", "*")
Fixes
com.github.kklisura.cdt.services.exceptions.ChromeServiceException: Server responded with non-200 code: 405 - Method Not Allowed. Using unsafe HTTP verb GET to invoke /json/new. This action supports only PUT verb.
In the meantime, I've created a fork and released it on Maven Central under io.fluidsonic.mirror:cdt-java-client:4.0.0-fluidsonic-1. This PR is the only change.
Thank you for you input. I've just added new issue regarding this case and also wanted to do something with that issue. :)
Thanks a lot, @fluidsonic. I am facing the same issue recently. I have verified that your branch and tips of the specific origin all are working fine for me.
Thanks @fluidsonic, much appreciated. You added to the readme about the launch arguments... I've had to add the option to ChromeArguments to get this working. I also made it default... perhaps the default could be the local IP address?
For anyone needing to fix the 101 continue 403 forbidden issue referenced in #87:
https://github.com/karlvr/chrome-devtools-java-client/commit/72d7264e193bdc5372c0e38f64af5922f61695ca
@fluidsonic Thank you for the fork and the origin workaround. It helped us enormously!
+1 on this. Thanks @fluidsonic for the patched library.
I checked the remote-allow-origins flag too and can confirm it must be set to '*', or I get a 'Failed connecting to tab web socket' error.
val args = ChromeArguments.defaults(true)
.headless()
.additionalArguments("no-sandbox", true)
.additionalArguments("remote-allow-origins", "*")
.build()
Given that remote-allow-origins is likely always required from Chrome 111+, would it make sense to also bake that in to the lib? It doesn't seem like the sort of thing that would break backwards compatibility.
Setting remote-allow-origins to * by default likely defeats the security purpose for which it was introduced. Explicitly setting it makes more sense for now as it highlights a potential security risk depending on the context.
It's mandatory to specify a port in the origin. But I have no idea how to figure out the port as the connection isn't set up at browser startup and there can probably even be multiple websocket connections at a time 🤔
In the meantime, I've created a fork and released it on Maven Central under
io.fluidsonic.mirror:cdt-java-client:4.0.0-fluidsonic-1. This PR is the only change.
Thanks a lot @fluidsonic, you are a life savior! :hugs:
@sinaa why not merge this PR? we have to use fluidsonics' build to have a working cdt client