"Failed connecting to ws server"

Hello to everyone,

Today I need to update the WebDrivers of Chrome because it was requested by Katalon Studio when I tried to run my test suites. So I updated them and after that an error occurs. If some has any idea why this happens and how to fix it, I will be very thankful to you!
p.s: Everything was working fine before the last update of the Chrome Web drivers in Katalon Studio

Caused by: com.github.kklisura.cdt.services.exceptions.WebSocketServiceException: Failed connecting to ws server {}

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html
================================================

03-15-2023 11:02:05 AM Test Cases/Offline

Elapsed time: 31,619s

Test Cases/Offline FAILED.
Reason:
com.github.kklisura.cdt.services.exceptions.ChromeServiceException: Failed connecting to tab web socket.
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.createDevToolsService(ChromeServiceImpl.java:206)
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.createDevToolsService(ChromeServiceImpl.java:161)
	at com.github.kklisura.cdt.services.ChromeService$createDevToolsService$0.call(Unknown Source)
	at com.katalon.cdp.CdpUtils.getService(CdpUtils.groovy:50)
	at com.katalon.cdp.CdpUtils$getService.call(Unknown Source)
	at Offline.run(Offline:27)
	at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
	at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
	at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1678874523282.run(TempTestCase1678874523282.groovy:25)
Caused by: com.github.kklisura.cdt.services.exceptions.WebSocketServiceException: Failed connecting to ws server {}
	at com.github.kklisura.cdt.services.impl.WebSocketServiceImpl.connect(WebSocketServiceImpl.java:120)
	at com.github.kklisura.cdt.services.impl.WebSocketServiceImpl.create(WebSocketServiceImpl.java:86)
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.lambda$new$0(ChromeServiceImpl.java:94)
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.createDevToolsService(ChromeServiceImpl.java:176)
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.createDevToolsService(ChromeServiceImpl.java:161)
	at com.github.kklisura.cdt.services.ChromeService$createDevToolsService$0.call(Unknown Source)
	at com.katalon.cdp.CdpUtils.getService(CdpUtils.groovy:50)
	at com.katalon.cdp.CdpUtils$getService.call(Unknown Source)
	at Script1666940750748.run(Script1666940750748.groovy:27)
	... 11 more
Caused by: javax.websocket.DeploymentException: Handshake error.
	at org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:679)
	at org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:717)
	at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:871)
	at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:516)
	at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:378)
	at com.github.kklisura.cdt.services.impl.WebSocketServiceImpl.connect(WebSocketServiceImpl.java:98)
	... 19 more
Caused by: org.glassfish.tyrus.core.HandshakeException: Response code was not 101: 403.
	at org.glassfish.tyrus.client.TyrusClientEngine.processResponse(TyrusClientEngine.java:320)
	at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleHandshake(GrizzlyClientFilter.java:346)
	at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleRead(GrizzlyClientFilter.java:315)
	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)

The reason why it may be failing for you now could be due to the breaking changes for Chrome 111, which are outlined here Support Chrome 111+ by fluidsonic · Pull Request #85 · kklisura/chrome-devtools-java-client · GitHub. I am not sure if the Katalon team will need to update their CDP plugin once a fix is implemented.

Adding “–remote-allow-origins=*” as a chrome option might solve your issue.

Thank you for the help. I have tried it, but unfortunately, it doesn’t help "–remote-allow-origins=*”

Thanks, this worked in our case. Had to add it both for Chrome and Chrome (headless), since we use a mix of these in our test suite collection.

I want to mention I’m having the same problems.
Both Katalon Studio and Katalon Runtime Engine show the same behavior: the test suites are started and the first testcase works fine (in our case, opening the browser). Any 2nd test case will crash with

2023-03-23 14:09:00.307 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/Rapporten/01 Forbearance overzicht
com.github.kklisura.cdt.services.exceptions.ChromeServiceException: Failed connecting to tab web socket.
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.createDevToolsService(ChromeServiceImpl.java:206)
	at com.github.kklisura.cdt.services.impl.ChromeServiceImpl.createDevToolsService(ChromeServiceImpl.java:161)
	at com.kms.katalon.core.util.CDTUtils.getService(CDTUtils.java:41)

Extra weird is that all test suites report a green status, no error or something else.

Can you show me how you manage to make it happen, maybe I’m not doing it the right way.

Go to Project, Settings and make sure to add that option to the Chrome arguments. See screenshot. Make sure to enter the argument with a double dash, something that goes wrong when copying it from this website due to HTML formatting.

Ahh, I love you! It works, my mistake was that I used Dictionary instead of List … Thank you for the help!

1 Like

You can also add it programmatically.

ChromeOptions co = new ChromeOptions();
co.addArguments("--remote-allow-origins=*")

System.setProperty('webdriver.chrome.driver', DriverFactory.getChromeDriverPath())

WebDriver driver = new ChromeDriver(co);
driver.get(url)

DriverFactory.changeWebDriver(driver)
ChromeDevToolsService cdts = CdpUtils.getService()
2 Likes