Skip to content
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

Cannot open URL 'http://localhost:9222/json/new': HTTP status was '405 Method Not Allowed' #111

Open
bakaburg1 opened this issue Apr 27, 2023 · 4 comments

Comments

@bakaburg1
Copy link

Hello,

I used to use crrri in the past and it worked well. Now I'm running a function written with it after some time and I get the following error:

cannot open URL 'http://localhost:9222/json/new': HTTP status was '405 Method Not Allowed'

My function is the following:

get_website_resources <- function(url, url_filter = ".*", type_filter = ".*",
                                  wait_for = 20,
                                  n_of_resources = NULL, interactive = FALSE) {

  # Silence CMD CHECK about non standard eval
  . <- NULL

  crrri::perform_with_chrome(function(client) {
    Fetch <- client$Fetch
    Page <- client$Page

    if (interactive) client$inspect()

    out <- new.env()

    out$results <- list()
    out$resolve_function <- NULL

    out$pr <- promises::promise(function(resolve, reject) {
      out$resolve_function <- resolve

      Fetch$enable(patterns = list(list(urlPattern = "*", requestStage = "Response"))) %...>%
        {
          Fetch$requestPaused(callback = function(params) {
            if (stringr::str_detect(params$request$url, url_filter) & stringr::str_detect(params$resourceType, type_filter)) {
              Fetch$getResponseBody(requestId = params$requestId) %...>% {
                resp <- .

                if (resp$body != "") {
                  if (resp$base64Encoded) resp$body <- jsonlite::base64_dec(resp$body) %>% rawToChar()

                  body <- list(list(
                    url = params$request$url,
                    response = resp
                  )) %>% setNames(params$requestId)

                  # str(body)

                  out$results <- append(out$results, body)

                  if (!is.null(n_of_resources) & length(out$results) >= n_of_resources) out$resolve_function(out$results)
                }
              }
            }

            Fetch$continueRequest(requestId = params$requestId)
          })
        } %...>%
        {
          Page$navigate(url)
        } %>%
        crrri::wait(wait_for) %>%
        crrri::then(~ out$resolve_function(out$results))
    })

    out$pr$then(function(x) x)
  }, timeouts = max(wait_for + 3, 30), cleaning_timeout = max(wait_for + 3, 30))
}

it is run like this:

get_website_resources(
      url = "https://ieeexplore.ieee.org/search/searchresult.jsp?queryText=Adversarial%20machine%20learning&rowsPerPage=100&ranges=2020_2020_Year",
      url_filter = "rest/search",
      type_filter = "XHR", wait_for = 20
    )

I used it the last time successfully a couple of years ago

@lisovyk
Copy link

lisovyk commented May 5, 2023

Running into the same issue :(

@staropram
Copy link

staropram commented Jun 15, 2023

if you try and manually browse to http://localhost:9222/json/new on chrome it says:

"Using unsafe HTTP verb GET to invoke /json/new. This action supports only PUT verb."

So I guess the chrome API has changed?

If you look at the backtrace:

    ▆
 1. └─chrome$connect()
 2.   └─self$connectToNewTab(callback = callback)
 3.     └─crrri::new_tab(...)
 4.       └─crrri:::fetch_json(host, port, secure, "new", url)

fetch_json calls jsonlite::fromJSON which itself gets the URL using base::url which does a GET and not a PUT. So if this is the issue it is a bit cumbersome to change.

I did have a play and create a crrri:::fetch_json_PUT and modified jsonlite to have a fromJSON_PUT and it did then get past that error. Everything then worked but clearly this isn't a good long-term solution. A solution would be to not use fromJSON if a put is needed.

@springhuasheng
Copy link

我在使用 java cdp4j 时使用 Session.create()也遇到了这个问题 : (

@springhuasheng
Copy link

我在使用 java cdp4j 时使用 Session.create()也遇到了这个问题 : (
有时候没问题, 有时候有问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants