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 run playwright tests on Selenium Grid. #18892

Open
dimsamaras opened this issue Nov 17, 2022 · 40 comments
Open

Cannot run playwright tests on Selenium Grid. #18892

dimsamaras opened this issue Nov 17, 2022 · 40 comments

Comments

@dimsamaras
Copy link

dimsamaras commented Nov 17, 2022

I have created a simple .net 6 console app to check whether it is possible to use Selenium Grid instead of Moon in order to have a svc managing the Browsers.

this is my dummy code Program.cs:

using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Channel = "chrome" });
var ctx = await browser.NewContextAsync(new BrowserNewContextOptions()
{
    IgnoreHTTPSErrors = true
});

var page = await ctx.NewPageAsync();

var url = "https://playwright.dev/dotnet/docs/intro";
var response = await page.GotoAsync(url, new PageGotoOptions
    {
        WaitUntil = WaitUntilState.DOMContentLoaded
    });

Console.WriteLine(response.Ok);

await page.ScreenshotAsync(new PageScreenshotOptions
{
    Path = "screenshot.png",
    FullPage = true
});

Console.WriteLine("Screenshot ok");

I have set the necessary env variables SELENIUM_REMOTE_URL

---> THE PROBLEM <---

The screenshot for full page times out.

If i remove the FullPage = true the screenshot succeeds.

Similarly, if i do a page.clickAsync() action it times out,

page.CloseAsync() works.

navigating to different pages with page.GoToAsync calls again works without issue.

It looks like some actions just do not work.

I am attaching the errors i get from the hub and the chrome pod.

  • SELENIUM HUB:
15:26:09.260 INFO [Node.<init>] - Binding additional locator mechanisms: name, id, relative
15:26:09.461 INFO [GridModel.setAvailability] - Switching Node ce697328-ea35-490b-94b5-e1afa3e0a67e (uri: http://10.244.1.71:5555/ ) from DOWN to UP
15:26:09.461 INFO [LocalDistributor.add] - Added node ce697328-ea35-490b-94b5-e1afa3e0a67e at http://10.244.1.71:5555/ . Health check every 120s
15:33:17.688 INFO [LocalDistributor.newSession] - Session request received by the Distributor:
[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-field-trial-config, --disable-background-networ..., --enable-features=NetworkSe..., --disable-background-timer-..., --disable-backgrounding-occ..., --disable-back-forward-cache, --disable-breakpad, --disable-client-side-phish..., --disable-component-extensi..., --disable-default-apps, --disable-dev-shm-usage, --disable-extensions, --disable-features=Improved..., --allow-pre-commit-input, --disable-hang-monitor, --disable-ipc-flooding-prot..., --disable-popup-blocking, --disable-prompt-on-repost, --disable-renderer-backgrou..., --disable-sync, --force-color-profile=srgb, --metrics-recording-only, --no-first-run, --enable-automation, --password-store=basic, --use-mock-keychain, --no-service-autorun, --export-tagged-pdf, --headless, --hide-scrollbars, --mute-audio, --blink-settings=primaryHov..., --no-sandbox, --remote-debugging-port=0]}}]
15:33:18.650 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 37972c369578e697a6be9360403fd256
Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: /tmp/.com.google.Chrome.sUT3Fb}, goog:chromeOptions: {debuggerAddress: localhost:42649}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: {}, se:bidiEnabled: false, se:cdp: ws://selenium-hub:4444/sess..., se:cdpVersion: 106.0.5249.119, se:vnc: ws://selenium-hub:4444/sess..., se:vncEnabled: true, se:vncLocalAddress: ws://10.244.1.71:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
15:33:20.031 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: [os.name](http://os.name/) : 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:232) at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda5.send(JdkHttpClient.java:232)atorg.openqa.selenium.netty.server.WebSocketMessageHandler.lambdachannelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.lambda5.lambdasend$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:222) ... 9 more 15:33:20.197 INFO [GridModel.release] - Releasing slot for session id 37972c369578e697a6be9360403fd256 15:33:20.197 INFO [LocalSessionMap.lambda5.send(JdkHttpClient.java:222)...9more15:33:20.197INFO[GridModel.release]−Releasingslotforsessionid37972c369578e697a6be9360403fd25615:33:20.197INFO[LocalSessionMap.lambdanew0] - Deleted session from local Session Map, Id: 37972c369578e697a6be9360403fd256 15:33:48.408 INFO [LocalDistributor.newSession] - Session request received by the Distributor: [Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-field-trial-config, --disable-background-networ..., --enable-features=NetworkSe..., --disable-background-timer-..., --disable-backgrounding-occ..., --disable-back-forward-cache, --disable-breakpad, --disable-client-side-phish..., --disable-component-extensi..., --disable-default-apps, --disable-dev-shm-usage, --disable-extensions, --disable-features=Improved..., --allow-pre-commit-input, --disable-hang-monitor, --disable-ipc-flooding-prot..., --disable-popup-blocking, --disable-prompt-on-repost, --disable-renderer-backgrou..., --disable-sync, --force-color-profile=srgb, --metrics-recording-only, --no-first-run, --enable-automation, --password-store=basic, --use-mock-keychain, --no-service-autorun, --export-tagged-pdf, --headless, --hide-scrollbars, --mute-audio, --blink-settings=primaryHov..., --no-sandbox, --remote-debugging-port=0]}}] 15:33:48.660 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 871135c74f65c9368403e2c5b587c386 Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: /tmp/.com.google.Chrome.bMGdRp}, goog:chromeOptions: {debuggerAddress: localhost:45765}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: {}, se:bidiEnabled: false, se:cdp: ws://selenium-hub:4444/sess..., se:cdpVersion: 106.0.5249.119, se:vnc: ws://selenium-hub:4444/sess..., se:vncEnabled: true, se:vncLocalAddress: ws://10.244.1.71:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} 15:33:49.590 WARN [ProxyWebsocketsIntoGridForwardingListener.onError] - Error proxying websocket command
java.net.ProtocolException
at java.net.http/jdk.internal.net.http.websocket.WebSocketImplReceiveTask.processError(WebSocketImpl.java:487) at java.net.http/jdk.internal.net.http.websocket.WebSocketImplReceiveTask.processError(WebSocketImpl.java:487)atjava.net.http/jdk.internal.net.http.websocket.WebSocketImplReceiveTask.run(WebSocketImpl.java:454)
at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147) at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147)atjava.net.http/jdk.internal.net.http.common.SequentialSchedulerSchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.trySetState(WebSocketImpl.java:837)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.signalError(WebSocketImpl.java:714)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImplSignallingMessageConsumer.onError(WebSocketImpl.java:825) at java.net.http/jdk.internal.net.http.websocket.TransportImplSignallingMessageConsumer.onError(WebSocketImpl.java:825)atjava.net.http/jdk.internal.net.http.websocket.TransportImplReceiveTask.run(TransportImpl.java:671)
at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147) at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147)atjava.net.http/jdk.internal.net.http.common.SequentialSchedulerSchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.websocket.TransportImplReadEvent.handle(TransportImpl.java:762) at java.net.http/jdk.internal.net.http.RawChannelTubeReadEvent.handle(TransportImpl.java:762)atjava.net.http/jdk.internal.net.http.RawChannelTubeReadSubscriber.checkEvents(RawChannelTube.java:174)
at java.net.http/jdk.internal.net.http.RawChannelTubeReadSubscriber.onNext(RawChannelTube.java:204) at java.net.http/jdk.internal.net.http.RawChannelTubeReadSubscriber.onNext(RawChannelTube.java:204)atjava.net.http/jdk.internal.net.http.RawChannelTubeReadSubscriber.onNext(RawChannelTube.java:157)
at java.net.http/jdk.internal.net.http.SocketTubeInternalReadPublisherInternalReadPublisherInternalReadSubscription.read(SocketTube.java:844)
at java.net.http/jdk.internal.net.http.SocketTubeSocketFlowTask.run(SocketTube.java:175) at java.net.http/jdk.internal.net.http.common.SequentialSchedulerSocketFlowTask.run(SocketTube.java:175)atjava.net.http/jdk.internal.net.http.common.SequentialSchedulerSchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.SocketTubeInternalReadPublisherInternalReadPublisherInternalReadSubscription.signalReadable(SocketTube.java:763)
at java.net.http/jdk.internal.net.http.SocketTubeInternalReadPublisherInternalReadPublisherReadEvent.signalEvent(SocketTube.java:941)
at java.net.http/jdk.internal.net.http.SocketTubeSocketFlowEvent.handle(SocketTube.java:245) at java.net.http/jdk.internal.net.http.HttpClientImplSocketFlowEvent.handle(SocketTube.java:245)atjava.net.http/jdk.internal.net.http.HttpClientImplSelectorManager.handleEvent(HttpClientImpl.java:957)
at java.net.http/jdk.internal.net.http.HttpClientImplSelectorManager.lambdaSelectorManager.lambdarun3(HttpClientImpl.java:912) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at java.net.http/jdk.internal.net.http.HttpClientImpl3(HttpClientImpl.java:912)atjava.base/java.util.ArrayList.forEach(ArrayList.java:1541)atjava.net.http/jdk.internal.net.http.HttpClientImplSelectorManager.run(HttpClientImpl.java:912)
Caused by: jdk.internal.net.http.websocket.FailWebSocketException: Unexpected frame CONTINUATION (fin=false)
at java.net.http/jdk.internal.net.http.websocket.MessageDecoder.opcode(MessageDecoder.java:133)
at java.net.http/jdk.internal.net.http.websocket.FrameReader.readFrame(Frame.java:391) at java.net.http/jdk.internal.net.http.websocket.TransportImplReader.readFrame(Frame.java:391)atjava.net.http/jdk.internal.net.http.websocket.TransportImplReceiveTask.run(TransportImpl.java:665)
... 20 more
15:34:19.584 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.io.IOException: Output closed
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: [os.name](http://os.name/) : 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:232) at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda5.send(JdkHttpClient.java:232)atorg.openqa.selenium.netty.server.WebSocketMessageHandler.lambdachannelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.io.IOException: Output closed at java.net.http/jdk.internal.net.http.websocket.MessageEncoder.encodeText(MessageEncoder.java:136) at java.net.http/jdk.internal.net.http.websocket.TransportImpl2.run(ThreadExecutorMap.java:74)atio.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)atjava.base/java.lang.Thread.run(Thread.java:829)Causedby:java.io.IOException:Outputclosedatjava.net.http/jdk.internal.net.http.websocket.MessageEncoder.encodeText(MessageEncoder.java:136)atjava.net.http/jdk.internal.net.http.websocket.TransportImplSendTask1.onText(TransportImpl.java:366) at java.net.http/jdk.internal.net.http.websocket.TransportImpl1.onText(TransportImpl.java:366)atjava.net.http/jdk.internal.net.http.websocket.TransportImplSendTask1.onText(TransportImpl.java:357) at java.net.http/jdk.internal.net.http.websocket.MessageQueue.peek(MessageQueue.java:223) at java.net.http/jdk.internal.net.http.websocket.TransportImpl1.onText(TransportImpl.java:357)atjava.net.http/jdk.internal.net.http.websocket.MessageQueue.peek(MessageQueue.java:223)atjava.net.http/jdk.internal.net.http.websocket.TransportImplSendTask.run(TransportImpl.java:545)
at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147) at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147)atjava.net.http/jdk.internal.net.http.common.SequentialSchedulerSchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.websocket.TransportImpl.sendText(TransportImpl.java:149)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendText(WebSocketImpl.java:184)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.lambda5.lambdasend$1(JdkHttpClient.java:211)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
15:34:19.585 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.io.IOException: Output closed
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: [os.name](http://os.name/) : 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:232) at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda5.send(JdkHttpClient.java:232)atorg.openqa.selenium.netty.server.WebSocketMessageHandler.lambdachannelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.io.IOException: Output closed at java.net.http/jdk.internal.net.http.websocket.MessageEncoder.encodeText(MessageEncoder.java:136) at java.net.http/jdk.internal.net.http.websocket.TransportImpl2.run(ThreadExecutorMap.java:74)atio.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)atjava.base/java.lang.Thread.run(Thread.java:829)Causedby:java.io.IOException:Outputclosedatjava.net.http/jdk.internal.net.http.websocket.MessageEncoder.encodeText(MessageEncoder.java:136)atjava.net.http/jdk.internal.net.http.websocket.TransportImplSendTask1.onText(TransportImpl.java:366) at java.net.http/jdk.internal.net.http.websocket.TransportImpl1.onText(TransportImpl.java:366)atjava.net.http/jdk.internal.net.http.websocket.TransportImplSendTask1.onText(TransportImpl.java:357) at java.net.http/jdk.internal.net.http.websocket.MessageQueue.peek(MessageQueue.java:223) at java.net.http/jdk.internal.net.http.websocket.TransportImpl1.onText(TransportImpl.java:357)atjava.net.http/jdk.internal.net.http.websocket.MessageQueue.peek(MessageQueue.java:223)atjava.net.http/jdk.internal.net.http.websocket.TransportImplSendTask.run(TransportImpl.java:545)
at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147) at java.net.http/jdk.internal.net.http.common.SequentialSchedulerCompleteRestartableTask.run(SequentialScheduler.java:147)atjava.net.http/jdk.internal.net.http.common.SequentialSchedulerSchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.websocket.TransportImpl.sendText(TransportImpl.java:149)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendText(WebSocketImpl.java:184)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.lambda5.lambdasend$1(JdkHttpClient.java:211)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
15:34:19.591 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: [os.name](http://os.name/) : 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:232) at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda5.send(JdkHttpClient.java:232)atorg.openqa.selenium.netty.server.WebSocketMessageHandler.lambdachannelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.lambda5.lambdasend$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:222) ... 9 more 15:34:19.673 INFO [GridModel.release] - Releasing slot for session id 871135c74f65c9368403e2c5b587c386 15:34:19.673 INFO [LocalSessionMap.lambda5.send(JdkHttpClient.java:222)...9more15:34:19.673INFO[GridModel.release]−Releasingslotforsessionid871135c74f65c9368403e2c5b587c38615:34:19.673INFO[LocalSessionMap.lambdanew$0] - Deleted session from local Session Map, Id: 871135c74f65c9368403e2c5b587c386
  • SELENIUM CHROME POD:
2022-11-17 15:26:04,639 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2022-11-17 15:26:04,643 INFO RPC interface 'supervisor' initialized
2022-11-17 15:26:04,643 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2022-11-17 15:26:04,643 INFO supervisord started with pid 9
2022-11-17 15:26:05,645 INFO spawned: 'xvfb' with pid 11
2022-11-17 15:26:05,646 INFO spawned: 'vnc' with pid 12
2022-11-17 15:26:05,647 INFO spawned: 'novnc' with pid 13
2022-11-17 15:26:05,649 INFO spawned: 'selenium-node' with pid 14
2022-11-17 15:26:05,666 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
Generating Selenium Config
Configuring server...
Setting up SE_NODE_HOST...
Setting up SE_NODE_PORT...
Selenium Grid Node configuration:
[events]
publish = "tcp://selenium-hub:4442"
subscribe = "tcp://selenium-hub:4443"
[node]
grid-url = "http://selenium-hub:4444/wd/hub/ "
session-timeout = "300"
override-max-sessions = false
detect-drivers = false
drain-after-session-count = 0
max-sessions = 1
[[node.driver-configuration]]
display-name = "chrome"
stereotype = '{"browserName": "chrome", "browserVersion": "106.0", "platformName": "Linux"}'
max-sessions = 1
Starting Selenium Grid Node...
2022-11-17 15:26:06,670 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-17 15:26:06,670 INFO success: vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-17 15:26:06,670 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
15:26:07.161 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
15:26:07.164 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
15:26:07.381 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://selenium-hub:4442 and tcp://selenium-hub:4443
15:26:07.562 INFO [UnboundZmqEventBus.<init>] - Sockets created
15:26:08.563 INFO [UnboundZmqEventBus.<init>] - Event bus ready
15:26:08.756 INFO [NodeServer.createHandlers] - Reporting self as: http://10.244.1.71:5555/ 
15:26:08.768 INFO [NodeOptions.getSessionFactories] - Detected 1 available processors
15:26:08.868 INFO [NodeOptions.report] - Adding chrome for {"browserVersion": "106.0","se:noVncPort": 7900,"browserName": "chrome","platformName": "LINUX","se:vncEnabled": true} 1 times
15:26:08.879 INFO [Node.<init>] - Binding additional locator mechanisms: id, relative, name
15:26:09.197 INFO [NodeServer$1.start] - Starting registration process for Node http://10.244.1.71:5555/ 
15:26:09.197 INFO [NodeServer.execute] - Started Selenium node 4.5.3 (revision 4b786a1e430): http://10.244.1.71:5555/ 
15:26:09.257 INFO [NodeServer1.lambda1.lambdastart1] - Sending registration event... 15:26:09.465 INFO [NodeServer.lambda1]−Sendingregistrationevent...15:26:09.465INFO[NodeServer.lambdacreateHandlers$2] - Node has been added
Starting ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}) on port 17620
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations  for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
15:33:18.577 INFO [LocalNode.newSession] - Session created by the Node. Id: 37972c369578e697a6be9360403fd256, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: /tmp/.com.google.Chrome.sUT3Fb}, goog:chromeOptions: {debuggerAddress: localhost:42649}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: http://localhost:42649/ , se:cdpVersion: 106.0.5249.119, se:vncEnabled: true, se:vncLocalAddress: ws://10.244.1.71:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
15:33:18.676 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://localhost:42649/devtools/browser/4cb31343-3639-4be6-95bf-0e2c0c39365d
15:33:20.063 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.5.3', revision: '4b786a1e430'
System info: [os.name](http://os.name/) : 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:232) at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda5.send(JdkHttpClient.java:232)atorg.openqa.selenium.netty.server.WebSocketMessageHandler.lambdachannelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.lambda5.lambdasend$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
15:33:20.196 INFO [SessionSlot.stop] - Stopping session 37972c369578e697a6be9360403fd256
Starting ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}) on port 22517
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations  for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
15:33:48.655 INFO [LocalNode.newSession] - Session created by the Node. Id: 871135c74f65c9368403e2c5b587c386, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: /tmp/.com.google.Chrome.bMGdRp}, goog:chromeOptions: {debuggerAddress: localhost:45765}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: http://localhost:45765/ , se:cdpVersion: 106.0.5249.119, se:vncEnabled: true, se:vncLocalAddress: ws://10.244.1.71:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
15:33:48.684 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://localhost:45765/devtools/browser/d15d481d-342d-4935-9f0d-88dbf2e95d2b
15:33:49.587 WARN [MessageInboundConverter.channelRead0] - Frame is not final. Chaos may ensue
15:33:49.591 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.5.3', revision: '4b786a1e430'
System info: [os.name](http://os.name/) : 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.send(JdkHttpClient.java:232) at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda5.send(JdkHttpClient.java:232)atorg.openqa.selenium.netty.server.WebSocketMessageHandler.lambdachannelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient5.lambda5.lambdasend$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
15:34:19.672 INFO [SessionSlot.stop] - Stopping session 871135c74f65c9368403e2c5b587c386

I have tried both with chrome and edge.
I have also tried different versions of playwright 1.17.3 to 1.27.2 and changed the browser versions on Selenium Grid deployment without any success :(

I also created another app that uses Selenium.Webdriver and everything works fine:

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Support.UI;

namespace WebScreenShot
{
    internal class Program
    {
        static void Main(string[] args)
        {
            CaptureWebPage("https://learnwithhasan.com");
        }

        public static void CaptureWebPage(string url)
        {
            var options = new ChromeOptions();
            //options.AddArgument("--headless");
            options.AddArgument("user-agent=Mozilla/5.0 " +
                "(Windows NT 10.0; Win64; x64) AppleWebKit/537.36" +
                " (KHTML, like Gecko) Chrome/74.0.3729.169 " +
                "Safari/537.36");

            RemoteWebDriver driver;

            //CHROME and IE            
            ChromeOptions Options = new ChromeOptions();

            driver = new RemoteWebDriver(
                new Uri("http://selenium-hub:4444/wd/hub/"),Options.ToCapabilities(), TimeSpan.FromSeconds(600));// NOTE: connection timeout of 600 seconds or more required for time to launch grid n

            driver.Navigate().GoToUrl(url);

            ITakesScreenshot screenshotDriver = 
                driver as ITakesScreenshot;
         
            //< a href = "https://learnwithhasan.com/google-ads-api-keyword-tool-csharp/" >
            //           Google Ads API: Build A Keyword Research Tool With C# For Free!			</a>
            WebDriverWait w = new WebDriverWait(driver, TimeSpan.FromSeconds(20));
            w.Until(drv => drv.FindElement(By.XPath("//a[@href='https://learnwithhasan.com/google-ads-api-keyword-tool-csharp/']")));
            var element= driver.FindElement(
                    By.XPath("//a[@href='https://learnwithhasan.com/google-ads-api-keyword-tool-csharp/']"));
               element.Click();
               Screenshot screenshot = screenshotDriver.GetScreenshot();
            screenshot.SaveAsFile("Test.png");
        }
    }
}

Thank you in advance!
Dimitris

@mxschmitt
Copy link
Member

Which Chromium version are you using on your Selenium Grid?

@mxschmitt mxschmitt transferred this issue from microsoft/playwright-dotnet Nov 17, 2022
@alfeg
Copy link

alfeg commented Nov 18, 2022

I can confirm this issue when using chrome node in docker or k8s
Tried: selenium/node-chrome:4.5 and selenium/node-chrome:4.6
Tried exact version from documentation.
One note: standalone-chrome docker is working fine. It's only fails when node is executed separatly.

Got almost same error message

	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:763)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:941)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:245)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:957)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:912)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:912)
Caused by: jdk.internal.net.http.websocket.FailWebSocketException: Unexpected frame CONTINUATION (fin=false)
	at java.net.http/jdk.internal.net.http.websocket.MessageDecoder.opcode(MessageDecoder.java:133)
	at java.net.http/jdk.internal.net.http.websocket.Frame$Reader.readFrame(Frame.java:391)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:665)
	... 20 more
07:34:43.882 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:232)
	at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:215)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
	... 9 more

Sample script that fails

const { chromium } = require('playwright')

; (async () => {
    const browser = await chromium.launch({headless: false})
    try {
        const page = await browser.newPage()
        await page.goto('https://danube-web.shop/')
        await page.click('#cart')            
        await page.screenshot({ path: 'screenshot.png', fullPage: true });
    } finally {
        await browser.close()
    }
})()

Chrome capabilities reported by Selenium Grid v4.6

{
  "acceptInsecureCerts": false,
  "browserName": "chrome",
  "browserVersion": "107.0.5304.87",
  "chrome": {
    "chromedriverVersion": "107.0.5304.62 (1eec40d3a5764881c92085aaee66d25075c159aa-refs/branch-heads/5304@{#942})",
    "userDataDir": "/tmp/.com.google.Chrome.wVB4XW"
  },
  "goog:chromeOptions": {
    "debuggerAddress": "localhost:45819"
  },
  "networkConnectionEnabled": false,
  "pageLoadStrategy": "normal",
  "platformName": "LINUX",
  "proxy": {},
  "se:bidiEnabled": false,
  "se:cdp": "ws://localhost:4444/session/bcb297d234597048541562b8d0b382dc/se/cdp",
  "se:cdpVersion": "107.0.5304.87",
  "se:vnc": "ws://localhost:4444/session/bcb297d234597048541562b8d0b382dc/se/vnc",
  "se:vncEnabled": true,
  "se:vncLocalAddress": "ws://10.240.0.9:7900",
  "setWindowRect": true,
  "strictFileInteractability": false,
  "timeouts": {
    "implicit": 0,
    "pageLoad": 300000,
    "script": 30000
  },
  "unhandledPromptBehavior": "dismiss and notify",
  "webauthn:extension:credBlob": true,
  "webauthn:extension:largeBlob": true,
  "webauthn:virtualAuthenticators": true
}

@dimsamaras
Copy link
Author

mxschmitt Playwright only can run on Chrome and Edge on Selenium grid [Playwright can connect to Selenium Grid Hub that runs Selenium 4 to launch Google Chrome or Microsoft Edge browser, instead of running browser on the local machine.

If you try without the channel param (in order to get Chromium or Firefox) you get an unsupported exception.
I tried with the version described on the Playwright release page (v1.27.2 -> Chrome v106, v1.17.3 -> Chrome 96, ...)

@alfeg
Copy link

alfeg commented Nov 18, 2022

@dimsamaras
I have tried to follow doc steps with hubs and nodes. It just don't work.

Any suggestion on how to debug this issue deeply to investigate what can go wrong?

@dimsamaras
Copy link
Author

@alfeg, thanks for taking a look at it!

I have installed Selenium Grid on Kubernetes using the templates found here: https://github.com/SeleniumHQ/docker-selenium/blob/trunk/charts/selenium-grid/README.md

After that i had no issue taking the logs for the hub and browser pods.

@alfeg
Copy link

alfeg commented Nov 21, 2022

Okay, my bad.

Take some time and completed run for different Selenium Grid version:

  • 4.3 works fine
  • 4.4 works fine
  • 4.5, 4.6 are failing with logs below

@mxschmitt can at this point I'm not sure should this bug belong to PW or to Selenium Grid itself.

Steps I've done

# Install basic grid latest version
helm install selenium-grid docker-selenium/selenium-grid

#Also set for chromeNode 
#  extraEnvironmentVariables:
#    - name: SE_NODE_GRID_URL
#      value: http://localhost:4444/wd/hub

kubectl -n selenium port-forward $POD_NAME 4444:4444

Executed js script above #18892 (comment)

Chrome pod (this pod has custom

[node]
grid-url = "http://localhost:4444/wd/hub"
session-timeout = "300"
override-max-sessions = false
detect-drivers = false
drain-after-session-count = 0
max-sessions = 1

[[node.driver-configuration]]
display-name = "chrome"
stereotype = '{"browserName": "chrome", "browserVersion": "107.0", "platformName": "Linux"}'
max-sessions = 1

Starting Selenium Grid Node...
2022-11-21 14:15:52,378 INFO success: xvfb entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-21 14:15:52,378 INFO success: vnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-11-21 14:15:52,378 INFO success: novnc entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
14:15:52.507 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
14:15:52.577 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
14:15:52.879 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://selenium-hub:4442 and tcp://selenium-hub:4443
14:15:53.075 INFO [UnboundZmqEventBus.<init>] - Sockets created
14:15:54.084 INFO [UnboundZmqEventBus.<init>] - Event bus ready
14:15:54.304 INFO [NodeServer.createHandlers] - Reporting self as: http://10.240.0.61:5555
14:15:54.385 INFO [NodeOptions.getSessionFactories] - Detected 1 available processors
14:15:54.418 INFO [NodeOptions.report] - Adding chrome for {"browserVersion": "107.0","se:noVncPort": 7900,"browserName": "chrome","platformName": "LINUX","se:vncEnabled": true} 1 times
14:15:54.484 INFO [Node.<init>] - Binding additional locator mechanisms: relative, id, name
14:15:54.811 INFO [NodeServer$1.start] - Starting registration process for Node http://10.240.0.61:5555
14:15:54.812 INFO [NodeServer.execute] - Started Selenium node 4.6.0 (revision 79f1c02ae20): http://10.240.0.61:5555
14:15:54.875 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
14:15:55.249 INFO [NodeServer.lambda$createHandlers$2] - Node has been added
Starting ChromeDriver 107.0.5304.62 (1eec40d3a5764881c92085aaee66d25075c159aa-refs/branch-heads/5304@{#942}) on port 26586
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
14:15:56.498 INFO [LocalNode.newSession] - Session created by the Node. Id: 238b0133e8c33a7e738fc5c14a12f259, Caps: Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 107.0.5304.87, chrome: {chromedriverVersion: 107.0.5304.62 (1eec40d3a576..., userDataDir: /tmp/.com.google.Chrome.r9DXWZ}, goog:chromeOptions: {debuggerAddress: localhost:35043}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: http://localhost:35043, se:cdpVersion: 107.0.5304.87, se:vncEnabled: true, se:vncLocalAddress: ws://10.240.0.61:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
14:15:56.790 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://localhost:35043/devtools/browser/bc7d1e88-90dd-4452-924c-4976308b2636
14:15:58.978 WARN [MessageInboundConverter.channelRead0] - Frame is not final. Chaos may ensue
14:15:58.992 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:232)
	at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:215)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
	... 9 more

This is hub pod

14:15:58.986 WARN [ProxyWebsocketsIntoGrid$ForwardingListener.onError] - Error proxying websocket command
java.net.ProtocolException
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$ReceiveTask.processError(WebSocketImpl.java:487)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$ReceiveTask.run(WebSocketImpl.java:454)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.trySetState(WebSocketImpl.java:837)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.signalError(WebSocketImpl.java:714)
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$SignallingMessageConsumer.onError(WebSocketImpl.java:825)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:671)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReadEvent.handle(TransportImpl.java:762)
	at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.checkEvents(RawChannelTube.java:174)
	at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onNext(RawChannelTube.java:204)
	at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onNext(RawChannelTube.java:157)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:844)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:763)
	at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:941)
	at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:245)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:957)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:912)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:912)
Caused by: jdk.internal.net.http.websocket.FailWebSocketException: Unexpected frame CONTINUATION (fin=false)
	at java.net.http/jdk.internal.net.http.websocket.MessageDecoder.opcode(MessageDecoder.java:133)
	at java.net.http/jdk.internal.net.http.websocket.Frame$Reader.readFrame(Frame.java:391)
	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:665)
	... 20 more
14:16:28.810 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.6.0', revision: '79f1c02ae20'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-1091-azure', java.version: '11.0.16'
Driver info: driver.version: unknown
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:232)
	at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:215)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
	... 9 more

@dgozman
Copy link
Contributor

dgozman commented Nov 21, 2022

@dimsamaras Could you run your playwright script with DEBUG=pw:api,pw:protocol and post the logs here? Since some APIs work, and others do not, the problem is most likely in the protocol version incompatibility between Playwright and Chrome. Logs might help us to better understand the problem.

@dimsamaras
Copy link
Author

dimsamaras commented Nov 21, 2022

Following @alfeg 's latest comment, i downgraded selenium grid deployment to 4.4 and it works fine.

I will re-upgrade the version and run with the new envs as suggested by @dgozman and post the logs.

Thank you all for the help!

@alfeg
Copy link

alfeg commented Nov 22, 2022

Attaching pw* log against 4.6 Selenium Grid
debug.log

@victor-schwarzacc
Copy link

I'm having a similar issue with the latests grid versions.
I'm using dynamic grid and got the error mentioned below.
The issues are reproducible with grid versions: 4.5.2, 4.5.3,4.6.0 .
With 4.5.0 it works perfectly fine.
Playwright versions I tries started from 1.26,27,28

In my scenario I'm connecting via CDP to an existing session .The only action working is navigate to a page ,after which we cannot do any other action.

<<<<<<<<<<<<<<<<<<<<<
Hub
16:36:50.634 INFO [LocalDistributor.newSession] - Session request received by the Distributor:
[Capabilities {acceptInsecureCerts: true, accessKey: eyJ4cC51IjoxMzY4NzYsInhwLnA..., browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, platform: ANY, proxy: {proxyAutoconfigUrl: http://wdm.qes.app.schwarz/:..., proxyType: PAC}, se:project: noProjectSet, se:recordVideo: true, testName: Quick Start Chrome Browser ..., version: }, Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, proxy: {proxyAutoconfigUrl: http://wdm.qes.app.schwarz/:..., proxyType: pac}, se:project: noProjectSet, se:recordVideo: true}]
16:36:57.095 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: a511759384c185b511f22bd0eb0d9858
Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: /tmp/.com.google.Chrome.YsR5Cz}, goog:chromeOptions: {debuggerAddress: localhost:33511}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: {proxyAutoconfigUrl: http://wdm.qes.app.schwarz/:..., proxyType: PAC}, se:bidiEnabled: false, se:cdp: ws://4.159.225.248:4444/ses..., se:cdpVersion: 106.0.5249.119, se:forwardCdp: ws://172.19.0.5:4444/sessio..., se:project: noProjectSet, se:recordVideo: true, se:vnc: ws://4.159.225.248:4444/ses..., se:vncEnabled: true, se:vncLocalAddress: ws://172.19.0.5:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
16:36:57.420 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.5.2', revision: '702c64f787c'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-39-generic', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:232)
at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
16:37:29.579 WARN [ProxyWebsocketsIntoGrid$ForwardingListener.onError] - Error proxying websocket command
java.net.ProtocolException
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$ReceiveTask.processError(WebSocketImpl.java:487)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$ReceiveTask.run(WebSocketImpl.java:454)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.trySetState(WebSocketImpl.java:837)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.signalError(WebSocketImpl.java:714)
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl$SignallingMessageConsumer.onError(WebSocketImpl.java:825)
at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:671)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReadEvent.handle(TransportImpl.java:762)
at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.checkEvents(RawChannelTube.java:174)
at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onNext(RawChannelTube.java:204)
at java.net.http/jdk.internal.net.http.RawChannelTube$ReadSubscriber.onNext(RawChannelTube.java:157)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.read(SocketTube.java:844)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowTask.run(SocketTube.java:175)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$InternalReadSubscription.signalReadable(SocketTube.java:763)
at java.net.http/jdk.internal.net.http.SocketTube$InternalReadPublisher$ReadEvent.signalEvent(SocketTube.java:941)
at java.net.http/jdk.internal.net.http.SocketTube$SocketFlowEvent.handle(SocketTube.java:245)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(HttpClientImpl.java:957)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(HttpClientImpl.java:912)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(HttpClientImpl.java:912)
Caused by: jdk.internal.net.http.websocket.FailWebSocketException: Unexpected frame CONTINUATION (fin=false)
at java.net.http/jdk.internal.net.http.websocket.MessageDecoder.opcode(MessageDecoder.java:133)
at java.net.http/jdk.internal.net.http.websocket.Frame$Reader.readFrame(Frame.java:391)
at java.net.http/jdk.internal.net.http.websocket.TransportImpl$ReceiveTask.run(TransportImpl.java:665)
... 20 more
16:38:16.748 INFO [LocalSessionMap.lambda$new$0] - Deleted session from local Session Map, Id: 468225a53186d0a9b4c6e706e961d09a
16:38:16.749 INFO [GridModel.release] - Releasing slot for session id 468225a53186d0a9b4c6e706e961d09a

Node:

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
16:36:50.637 INFO [DockerSessionFactory.apply] - Starting session for Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [], extensions: []}, proxy: {proxyAutoconfigUrl: http://wdm.qes.app.schwarz/:..., proxyType: pac}, se:project: noProjectSet, se:recordVideo: true}
16:36:50.637 INFO [DockerSessionFactory.apply] - Creating container...
16:36:50.666 INFO [Container.] - Created container 160a013019e9cfe358969d6ab6b9a357e0653ac0fa2186fcd2f0cade952e56a4
16:36:50.666 INFO [Container.start] - Starting container 160a013019e9cfe358969d6ab6b9a357e0653ac0fa2186fcd2f0cade952e56a4
16:36:51.029 INFO [Container.inspect] - Inspecting container 160a013019e9cfe358969d6ab6b9a357e0653ac0fa2186fcd2f0cade952e56a4
16:36:51.036 INFO [DockerSessionFactory.apply] - Waiting for server to start (container id: 160a013019e9cfe358969d6ab6b9a357e0653ac0fa2186fcd2f0cade952e56a4, url http://172.19.0.5:4444/wd/hub)
16:36:54.226 INFO [DockerSessionFactory.apply] - Server is ready (container id: 160a013019e9cfe358969d6ab6b9a357e0653ac0fa2186fcd2f0cade952e56a4)
16:36:55.160 INFO [Container.] - Created container 4a3ec7ee921654939b634728a6f1626f1052bcc26bb720972379aa3ca825d3c3
16:36:55.161 INFO [Container.start] - Starting container 4a3ec7ee921654939b634728a6f1626f1052bcc26bb720972379aa3ca825d3c3
16:36:55.579 INFO [Container.inspect] - Inspecting container 4a3ec7ee921654939b634728a6f1626f1052bcc26bb720972379aa3ca825d3c3
16:36:57.089 INFO [DockerSessionFactory.startVideoContainer] - Video container started (id: 4a3ec7ee921654939b634728a6f1626f1052bcc26bb720972379aa3ca825d3c3)
16:36:57.091 INFO [LocalNode.newSession] - Session created by the Node. Id: a511759384c185b511f22bd0eb0d9858, Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: /tmp/.com.google.Chrome.YsR5Cz}, goog:chromeOptions: {debuggerAddress: localhost:33511}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(pac: http://wdm.qes.a/..., se:bidiEnabled: false, se:cdp: ws://4.159.225.248:4444/ses..., se:cdpVersion: 106.0.5249.119, se:forwardCdp: ws://172.19.0.5:4444/sessio..., se:project: noProjectSet, se:recordVideo: true, se:vnc: ws://4.159.225.248:4444/ses..., se:vncEnabled: true, se:vncLocalAddress: ws://172.19.0.5:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
16:36:59.809 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://172.19.0.5:7900
16:37:14.983 INFO [ProxyNodeWebsockets.apply] - Found endpoint where CDP connection needs to be forwarded
16:37:14.983 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://172.19.0.5:4444/session/a511759384c185b511f22bd0eb0d9858/se/fwd
16:37:29.578 WARN [MessageInboundConverter.channelRead0] - Frame is not final. Chaos may ensue
16:37:29.579 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.5.2', revision: '702c64f787c'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-39-generic', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:232)
at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
16:38:12.147 INFO [LocalNode.lambda$new$3] - Session id 468225a53186d0a9b4c6e706e961d09a timed out, stopping...
16:38:12.156 INFO [Container.stop] - Stopping container a6470200132062fc2cd54f46b7c0c1c28a799c66a72a53ed8a73f66e89f06147
16:38:12.669 INFO [Container.getLogs] - Getting logs 2d6262bf1d1b388212fbe2af6254bb68ac5abe4e9de3a6897fdd33a7883ce9a8
16:38:12.669 INFO [V141Docker.getContainerLogs] - Getting container logs: 2d6262bf1d1b388212fbe2af6254bb68ac5abe4e9de3a6897fdd33a7883ce9a8
16:38:12.672 INFO [Container.stop] - Stopping container 2d6262bf1d1b388212fbe2af6254bb68ac5abe4e9de3a6897fdd33a7883ce9a8
16:38:16.539 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
org.openqa.selenium.WebDriverException: java.lang.IllegalArgumentException: statusCode
Build info: version: '4.5.2', revision: '702c64f787c'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-39-generic', java.version: '11.0.16'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:232)
at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.IllegalArgumentException: statusCode
at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendClose(WebSocketImpl.java:301)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$2(JdkHttpClient.java:215)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:222)
... 9 more
16:38:16.747 INFO [SessionSlot.stop] - Stopping session 468225a53186d0a9b4c6e706e961d09a

@sohambbh
Copy link

I'm also facing a similar issue with the latest grid versions.
The issues are reproducible with grid versions: 4.5.2, 4.5.3,4.6.0 .
Surprisingly With 4.5.0 it works perfectly fine. Playwright versions I tried all > 1.19

with the selenium grid its able to connect. It launches the browser and even navigates to the url. But after that it doesn't interact with the grid.

grid log says - WARN [ProxyWebsocketsIntoGrid$ForwardingListener.onError] - Error proxying websocket command
java.net.ProtocolException

@dgozman
Copy link
Contributor

dgozman commented Nov 25, 2022

grid log says - WARN [ProxyWebsocketsIntoGrid$ForwardingListener.onError] - Error proxying websocket command
java.net.ProtocolException

Playwright does indeed use proxying websocket functionality. We'll take a look, but for now I'd suggest to stay on 4.5.0 since that seems to work.

@alfeg
Copy link

alfeg commented Dec 12, 2022

Just to keep up to date
Same issue is in Selenium Grid v4.7.1

@Schtil
Copy link

Schtil commented Jan 10, 2023

I have encountered a similar problem and any version after 4.5.0 including the latest at the moment 4.7.2 does not allow to interact with the page.
Is there any news?

@sridharreddysuram123
Copy link

With 4.7.2 Selenium, we are unable to perform any action such as click/type etc.. Only Launch URL is working. Any update on this?

@wodyjowski
Copy link
Contributor

I have the same exact issue with selenium grid versions mentioned above.

@dimsamaras
Copy link
Author

@wodyjowski, @sridharreddysuram123, @Schtil, @alfeg, @sohambbh,
Up to version 4.4 is ok.
I am switching back to Moon! It works a lot better and with all the browsers

@CkumarGitHub
Copy link

CkumarGitHub commented Jan 16, 2023

Similar Issue with GRID 4.7.2

com.microsoft.playwright.PlaywrightException: Error {
message='WebSocket error: connect ETIMEDOUT 172.18.0.3:4444
=========================== logs ===========================
connecting to http://localhost:4444/wd/hub/
connected to sessionId=0d7a9c4fb3cca0e73df6b6531ad85f7e
using selenium v4
retrieved endpoint ws://172.18.0.3:4444/session/0d7a9c4fb3cca0e73df6b6531ad85f7e/se/cdp for sessionId=0d7a9c4fb3cca0e73df6b6531ad85f7e
ws://172.18.0.3:4444/session/0d7a9c4fb3cca0e73df6b6531ad85f7e/se/cdp
error connect ETIMEDOUT 172.18.0.3:4444
ws://172.18.0.3:4444/session/0d7a9c4fb3cca0e73df6b6531ad85f7e/se/cdp connect ETIMEDOUT 172.18.0.3:4444
ws://172.18.0.3:4444/session/0d7a9c4fb3cca0e73df6b6531ad85f7e/se/cdp code=1006 reason=
disconnecting from sessionId=0d7a9c4fb3cca0e73df6b6531ad85f7e
disconnected from sessionId=0d7a9c4fb3cca0e73df6b6531ad85f7e

name='Error
stack='Error: WebSocket error: connect ETIMEDOUT 172.18.0.3:4444

@sridharreddysuram123
Copy link

@dgozman any update on this?

@CkumarGitHub
Copy link

@dgozman
For my error the node URI is ws://172.18.0.3:4444. But it should be something like //172.18.0.3:5555 as displayed in GRID.
Not sure its an issue from playwright side or not

@wodyjowski
Copy link
Contributor

@dimsamaras thankfully issue can be resolved by only downgrading the selenium-hub container to 4.5.0 (the nodes can use latest images to keep the newest chrome version).
I suspect something went wrong with our java friends side.

@wodyjowski
Copy link
Contributor

Selenium guys have two issues for this:
SeleniumHQ/selenium#11408
SeleniumHQ/docker-selenium#1729
(both closed)
The first one seems like it was going somewhere.

@CkumarGitHub
Copy link

@wodyjowski How do you downgrade the selenium-hub container to 4.5.0?

@wodyjowski
Copy link
Contributor

@wodyjowski How do you downgrade the selenium-hub container to 4.5.0?

You can do it by using separate images for hub and nodes (not the "standalone" version).
Something like that (in docker compose) 🫴

version: "3"
services:
  selenium-hub:
    image: selenium/hub:4.5.0
    container_name: selenium-hub
    ports:
      - "4444:4444"
    environment:
      - GRID_TIMEOUT=30
      - GRID_BROWSER_TIMEOUT=600

  selenium-node-chrome2:
    image: selenium/node-chrome:4.7.2
    shm_size: 2g
    depends_on:
      - selenium-hub
    environment:
      - SE_NODE_MAX_SESSIONS=2
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
      - SE_NODE_GRID_URL=http://localhost:4444

@Schtil
Copy link

Schtil commented Jan 24, 2023

However, I think it is important to say that this is not a solution to the problem.

@CkumarGitHub
Copy link

@wodyjowski
I tried running on Grid 4.5.0 but got the same error

image

Screenshot 2023-01-24 at 9 51 27 PM

Screenshot 2023-01-24 at 9 51 39 PM

@wodyjowski
Copy link
Contributor

@CkumarGitHub you're not setting up the grid properly.
Look at the address you're getting in the response - 172.18.0.3.
You didn't add the SE_NODE_GRID_URL=http://localhost:4444 variable to node/nodes.
Just use the docker compose I provided or the example:
https://github.com/wodyjowski/playwright-selenium-grid-ws-issue (change the version in yml to 4.5.0)

@sohambbh
Copy link

sohambbh commented Jan 24, 2023

We are unfortunately using a separate grid for playwright only. The reason is in 4.5.0 version - selenium grid has some hard waits which was fixed in later version. So we cant go back and have the slow execution for all other types of test.

@sohambbh
Copy link

image

Also as per above comment from a selenium project core member in SeleniumHQ/docker-selenium#1729 - Selenium grid doesn't support playwright. But playwright says in its webpage that it supports selenium grid. So I think the responsibility is more with playwright project now. Please let us know your thoughts on this bug. If there is no plan kindly let us know , then we will start migrating from playwright to selenium.

@wodyjowski
Copy link
Contributor

I'm not a Microsoft employee (yet) so I can't speak for them but as you can read in SeleniumHQ/selenium#11408 the issue occures even in example written in GO and some random Chrome DevTools Protocol implementation.
I've created another ticket for it: SeleniumHQ/selenium#11590
Maybe you guys could live some comments to create some pressure (I hope they fix it before the 2023 layoffs arrive at SeleniumHQ).

@evertones
Copy link
Contributor

evertones commented Feb 16, 2023

I found the same issue reported here. And I could have it working with Selenium Grid versions prior to 4.5.0.

I've been working with Selenium in the past years and had difficulty upgrading to a stable version of Selenium 4.*. It was possible only after 4.5.0 (actually, without some customisation, just after 4.6.0).
There is a big change in version 4.5.0 that replaced the HTTP client from async-http-client (based on Netty) with the native Java HTTP Client.

This blog post explains:

It seems the main issue reported here is related to this change and how web sockets communicate internally and with the library in Selenium Grid.
Exceptions have references to Netty (io.netty.*) packages and classes.

selenium-hub    | 05:28:42.141 WARN [DefaultChannelPipeline.onUnhandledInboundException] - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
selenium-hub    | org.openqa.selenium.WebDriverException: java.io.IOException: Output closed
selenium-hub    | Build info: version: '4.8.0', revision: '267030adea'
selenium-hub    | System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-128-generic', java.version: '11.0.17'
selenium-hub    | Driver info: driver.version: unknown
selenium-hub    | 	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:239)
selenium-hub    | 	at org.openqa.selenium.netty.server.WebSocketMessageHandler.lambda$channelRead0$0(WebSocketMessageHandler.java:47)
selenium-hub    | 	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
selenium-hub    | 	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
selenium-hub    | 	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
selenium-hub    | 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
selenium-hub    | 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
selenium-hub    | 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
selenium-hub    | 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
selenium-hub    | 	at java.base/java.lang.Thread.run(Thread.java:829)
selenium-hub    | Caused by: java.io.IOException: Output closed
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.MessageEncoder.encodeText(MessageEncoder.java:136)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask$1.onText(TransportImpl.java:366)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask$1.onText(TransportImpl.java:357)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.MessageQueue.peek(MessageQueue.java:223)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask.run(TransportImpl.java:545)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$CompleteRestartableTask.run(SequentialScheduler.java:147)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.common.SequentialScheduler$SchedulableTask.run(SequentialScheduler.java:198)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:271)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.common.SequentialScheduler.runOrSchedule(SequentialScheduler.java:224)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.TransportImpl.sendText(TransportImpl.java:149)
selenium-hub    | 	at java.net.http/jdk.internal.net.http.websocket.WebSocketImpl.sendText(WebSocketImpl.java:184)
selenium-hub    | 	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.lambda$send$1(JdkHttpClient.java:218)
selenium-hub    | 	at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:229)

My guess is that Playwright would have to be internally changed to communicate with Selenium Grid, following the upgrade from Selenium 4.5.0, although this is just a guess.

@Schtil
Copy link

Schtil commented Feb 16, 2023

@evertones Thank you for your participation in solving this problem.

Tell me, were you able to reproduce the problem using Selenium directly, without Playwright?

I'm asking because it seems that the SeleniumGrid developers are more talkative in this regard (at least no Microsoft developers have been here yet :( (from November 2022) )
And they are asking to reproduce the problem using Selenium with SeleniumGrid 4.5.0+

@evertones
Copy link
Contributor

evertones commented Feb 16, 2023

@Schtil : The original problem solved by moving from async-http-client to Java HTTP Library is the following:

It was reported in May/2021 and solved only in November/2022 after a lot of discussion and tests.
I doubt that it will be reproducible with Selenium anymore since they have implemented and released the fix for Selenium.

I could test different versions of Selenium Grid with Playwright and see that:

  • in the docker-selenium image 4.5.0-20221017, the tests pass
  • in the docker-selenium image 4.5.2-20221021, the tests fail with the error reported in this issue (there aren't releases in between - e.g. 4.5.1.*)

It's possible to see in the release notes of 4.5.2-20221021 that it started to use the new HTTP Client in all docker images of Selenium, as seen in this commit:

By saying that, I truly believe the problem is related to the changes in the HTTP Client, however, as @diemol (core Selenium member) said in a comment mentioned here, it should not be a problem that Selenium team must solve, but Playwright team.

@evertones
Copy link
Contributor

evertones commented Feb 18, 2023

@Schtil: I could make this work with the suggestion from EndPositive in this comment.

He suggests a workaround to increase the WebSocket buffer size by adding the following:

  • -Djdk.httpclient.websocket.intermediateBufferSize=3000000

I created a docker-compose.yml file with the following and ran tests with Playwright in a grid with 8 nodes. Tests passed.

version: "3"

services:
  selenium-hub:
    image: selenium/hub:4.8.0-20230210
    container_name: selenium-hub
    ports:
      - "4442:4442"
      - "4443:4443"
      - "4444:4444"
    environment:
      - JAVA_OPTS=-Djdk.httpclient.websocket.intermediateBufferSize=3000000
      - SE_EVENT_BUS_HOST=selenium-hub

  chrome:
    image: selenium/node-chrome:4.8.0-20230210
    shm_size: 2gb
    depends_on:
      - selenium-hub
    environment:
      - JAVA_OPTS=-Djdk.httpclient.websocket.intermediateBufferSize=3000000
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
      - SE_NODE_GRID_URL=http://localhost:4444

I believe that if Playwright needs a bigger WebSocket than supported by default in Selenium, the documentation should be updated and it would be Playwright's responsibility to indicate the custom config to make it work.

@sridharreddysuram123
Copy link

Team,
Any update on this ?

@diemol
Copy link

diemol commented Apr 20, 2023

Also leaving this comment, we are open for collaboration folks.

@wodyjowski
Copy link
Contributor

@diemol here you go: https://github.com/wodyjowski/SeleniumIssue
Example made using only official Selenium.WebDriver package and DevToolsSession in .NET.

@diemol
Copy link

diemol commented Apr 24, 2023

I'll reopen the Selenium issue and have a look. What is the plan you folks have when Selenium drops CDP support and only relies on BiDi? Have you checked it already?

@wodyjowski
Copy link
Contributor

@diemol I see that you've made a fix and closed your issue - when will it be available?
Latest selenium/hub:4.9.1 seems to still fail on my example.
As for BiDi implementation I have no idea since I'm still waiting for my Microsoft job offer, maybe @dgozman, @mxschmitt or @aslushnikov can answer this question.

Will Selenium Driver suddenly drop HTTP and switch do BiDi?

@diemol
Copy link

diemol commented May 31, 2023

It won't be sudden, there will be enough deprecation notice before moving to BiDi completely.

sylbn added a commit to Neotys-Labs/docker-selenium-kube that referenced this issue Jun 29, 2023
Increase ws size and provide SE_NODE_GRID_URL
microsoft/playwright#18892
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests