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

[🐛 Bug]: Standalone server: "Internal Server Error" when starting new session via HTTP POST #14463

Closed
fehmud opened this issue Sep 1, 2024 · 4 comments

Comments

@fehmud
Copy link

fehmud commented Sep 1, 2024

[I determined that I was using an old-style request (see next comment), but still the server should have returned a Bad Request error and not after 5 minutes.]

What happened?

Standalone server en Linux returns "Internal Server Error" when starting new Firefox session via HTTP POST "/session". Starting a new Firefox works with the .NET WebDriver client.

How can we reproduce the issue?

Start standalone server:

    $ java -jar selenium-server-4.24.0.jar standalone --port 4444 --selenium-manager true

From the same PC, send request via Postman equivalent to this command:

    curl --location 'http://127.0.0.1:4444/session' \
         --header 'Content-Type: application/json; charset=utf-8' \
         --header 'Accept: application/json; charset=utf-8' \
         --data '{"desiredCapabilities":{"browserName":"firefox","version":"", "javascriptEnabled": true}}'

Relevant log output

Started standalone server:

    $ java -jar selenium-server-4.24.0.jar standalone --port 4444 --selenium-manager true
    10:43:55.893 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
    10:43:55.897 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
    10:43:56.451 INFO [NodeOptions.getSessionFactories] - Detected 8 available processors
    10:43:56.598 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome","platformName": "linux"} 8 times
    10:43:56.599 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox","platformName": "linux"} 8 times
    10:43:56.600 INFO [NodeOptions.report] - Adding Edge for {"browserName": "MicrosoftEdge","platformName": "linux"} 8 times
    10:43:56.659 INFO [Node.<init>] - Binding additional locator mechanisms: relative
    10:43:56.675 INFO [GridModel.setAvailability] - Switching Node 4c82b479-9412-4b96-abc8-003f0f8d8cab (uri: http://192.168.236.181:4444) from DOWN to UP
    10:43:56.676 INFO [LocalDistributor.add] - Added node 4c82b479-9412-4b96-abc8-003f0f8d8cab at http://192.168.236.181:4444. Health check every 120s
    10:43:56.775 INFO [Standalone.execute] - Started Selenium Standalone 4.24.0 (revision 748ffc9bc3): http://192.168.236.181:4444

From the same PC, sent request via Postman equivalent to this command:

    curl --location 'http://127.0.0.1:4444/session' \
         --header 'Content-Type: application/json; charset=utf-8' \
         --header 'Accept: application/json; charset=utf-8' \
         --data '{"desiredCapabilities":{"browserName":"firefox","version":"", "javascriptEnabled": true}}'

After 5 minutes, I get an HTTP 500 "Internal Server Error", and the server logs this line:

    10:49:52.775 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "e2f23f33f4e078a03d3492f7b730c494","eventTime": 1725180592771316674,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue","http.host": "127.0.0.1:4444","http.method": "POST","http.request_content_length": "89","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession","http.user_agent": "PostmanRuntime\u002f7.41.2"}}

This is the HTTP exchange recorded by Postman:

    POST http://127.0.0.1:4444/session: {
      "Network": {
        "addresses": {
          "local": {
            "address": "127.0.0.1",
            "family": "IPv4",
            "port": 35204
          },
          "remote": {
            "address": "127.0.0.1",
            "family": "IPv4",
            "port": 4444
          }
        }
      },
      "Request Headers": {
        "content-type": "application/json; charset=utf-8",
        "accept": "application/json; charset=utf-8",
        "user-agent": "PostmanRuntime/7.41.2",
        "postman-token": "90368377-0485-49d8-b2d1-521cf2c1dfbe",
        "host": "127.0.0.1:4444",
        "accept-encoding": "gzip, deflate, br",
        "connection": "keep-alive",
        "content-length": "89"
      },
      "Request Body": "{\"desiredCapabilities\":{\"browserName\":\"firefox\",\"version\":\"\", \"javascriptEnabled\": true}}",
      "Response Headers": {
        "content-length": "9490",
        "cache-control": "no-cache",
        "content-type": "application/json; charset=utf-8"
      },
      "Response Body": /* see below */
    }

For your convenience, here is the pretty-printed response body:

    {
        "value": {
            "error": "session not created",
            "message": "Could not start a new session. New session request timed out \nHost info: host: 'laptop', ip: '127.0.1.1'\nBuild info: version: '4.24.0', revision: '748ffc9bc3'\nSystem info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-119-generic', java.version: '11.0.24'\nDriver info: driver.version: unknown",
            "stacktrace": [
                {
                    "fileName": "LocalNewSessionQueue.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "addToQueue",
                    "className": "org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue",
                    "lineNumber": 221,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "NewSessionQueue.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$new$0",
                    "className": "org.openqa.selenium.grid.sessionqueue.NewSessionQueue",
                    "lineNumber": 68,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "handle",
                    "className": "org.openqa.selenium.remote.http.Route$TemplatizedRoute",
                    "lineNumber": 192,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Route",
                    "lineNumber": 69,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "handle",
                    "className": "org.openqa.selenium.remote.http.Route$CombinedRoute",
                    "lineNumber": 360,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Route",
                    "lineNumber": 69,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "NewSessionQueue.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.grid.sessionqueue.NewSessionQueue",
                    "lineNumber": 128,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "SpanWrappedHttpHandler.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler",
                    "lineNumber": 87,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Filter.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Filter$1",
                    "lineNumber": 63,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "handle",
                    "className": "org.openqa.selenium.remote.http.Route$CombinedRoute",
                    "lineNumber": 360,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Route",
                    "lineNumber": 69,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Router.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.grid.router.Router",
                    "lineNumber": 87,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "CheckOriginHeader.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$apply$0",
                    "className": "org.openqa.selenium.grid.web.CheckOriginHeader",
                    "lineNumber": 69,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "CheckContentTypeHeader.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$apply$0",
                    "className": "org.openqa.selenium.grid.web.CheckContentTypeHeader",
                    "lineNumber": 75,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "EnsureSpecCompliantResponseHeaders.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$apply$0",
                    "className": "org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders",
                    "lineNumber": 34,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Filter.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Filter$1",
                    "lineNumber": 63,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "handle",
                    "className": "org.openqa.selenium.remote.http.Route$CombinedRoute",
                    "lineNumber": 360,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Route.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Route",
                    "lineNumber": 69,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "AddWebDriverSpecHeaders.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$apply$0",
                    "className": "org.openqa.selenium.remote.AddWebDriverSpecHeaders",
                    "lineNumber": 35,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "ErrorFilter.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$apply$0",
                    "className": "org.openqa.selenium.remote.ErrorFilter",
                    "lineNumber": 44,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Filter.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Filter$1",
                    "lineNumber": 63,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "ErrorFilter.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$apply$0",
                    "className": "org.openqa.selenium.remote.ErrorFilter",
                    "lineNumber": 44,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Filter.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "execute",
                    "className": "org.openqa.selenium.remote.http.Filter$1",
                    "lineNumber": 63,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "SeleniumHandler.java",
                    "moduleVersion": null,
                    "moduleName": null,
                    "nativeMethod": false,
                    "methodName": "lambda$channelRead0$0",
                    "className": "org.openqa.selenium.netty.server.SeleniumHandler",
                    "lineNumber": 44,
                    "classLoaderName": "app"
                },
                {
                    "fileName": "Executors.java",
                    "moduleVersion": "11.0.24",
                    "moduleName": "java.base",
                    "nativeMethod": false,
                    "methodName": "call",
                    "className": "java.util.concurrent.Executors$RunnableAdapter",
                    "lineNumber": 515,
                    "classLoaderName": null
                },
                {
                    "fileName": "FutureTask.java",
                    "moduleVersion": "11.0.24",
                    "moduleName": "java.base",
                    "nativeMethod": false,
                    "methodName": "run",
                    "className": "java.util.concurrent.FutureTask",
                    "lineNumber": 264,
                    "classLoaderName": null
                },
                {
                    "fileName": "ThreadPoolExecutor.java",
                    "moduleVersion": "11.0.24",
                    "moduleName": "java.base",
                    "nativeMethod": false,
                    "methodName": "runWorker",
                    "className": "java.util.concurrent.ThreadPoolExecutor",
                    "lineNumber": 1128,
                    "classLoaderName": null
                },
                {
                    "fileName": "ThreadPoolExecutor.java",
                    "moduleVersion": "11.0.24",
                    "moduleName": "java.base",
                    "nativeMethod": false,
                    "methodName": "run",
                    "className": "java.util.concurrent.ThreadPoolExecutor$Worker",
                    "lineNumber": 628,
                    "classLoaderName": null
                },
                {
                    "fileName": "Thread.java",
                    "moduleVersion": "11.0.24",
                    "moduleName": "java.base",
                    "nativeMethod": false,
                    "methodName": "run",
                    "className": "java.lang.Thread",
                    "lineNumber": 829,
                    "classLoaderName": null
                }
            ]
        }
    }

Operating System

Linux Mint 21.1 Cinnamon - Kernel 5.15.0-119-generic

Selenium version

None, I'm testing HTTP requests to write a new WebDriver client.

What are the browser(s) and version(s) where you see this issue?

Firefox v129.0 (64-bit)

What are the browser driver(s) and version(s) where you see this issue?

Don't know.

Are you using Selenium Grid?

4.24.0

Copy link

github-actions bot commented Sep 1, 2024

@fehmud, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@fehmud
Copy link
Author

fehmud commented Sep 1, 2024

Regrettably, I was using an old-style request content. The correct content is:

{
  "capabilities": {
    "alwaysMatch": {
      "browserName": "firefox",
      "browserVersion": "",
      "moz:firefoxOptions": {
        "args": [
          "--no-sandbox"
        ],
        "prefs": {
          "javascript.enabled": true
        }
      }
    }
  }
}

@diemol
Copy link
Member

diemol commented Sep 2, 2024

Glad you sorted it out.

@diemol diemol closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2024
Copy link

github-actions bot commented Oct 2, 2024

This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants