chrome-devtools-java-client icon indicating copy to clipboard operation
chrome-devtools-java-client copied to clipboard

Support Chrome 111+

Open fluidsonic opened this issue 2 years ago • 9 comments
trafficstars

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.

fluidsonic avatar Mar 08 '23 14:03 fluidsonic

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.

fluidsonic avatar Mar 09 '23 11:03 fluidsonic

Thank you for you input. I've just added new issue regarding this case and also wanted to do something with that issue. :)

elfoxus avatar Mar 09 '23 15:03 elfoxus

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.

imspzero avatar Mar 11 '23 13:03 imspzero

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

karlvr avatar Mar 15 '23 02:03 karlvr

@fluidsonic Thank you for the fork and the origin workaround. It helped us enormously!

nablex avatar Mar 15 '23 08:03 nablex

+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.

sporritt avatar Mar 23 '23 06:03 sporritt

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 🤔

fluidsonic avatar Mar 23 '23 06:03 fluidsonic

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:

pmrelvas avatar Jun 01 '23 10:06 pmrelvas

@sinaa why not merge this PR? we have to use fluidsonics' build to have a working cdt client

JAndrassy avatar Jul 25 '24 15:07 JAndrassy