selenium: [π Bug]: `org.openqa.selenium.WebDriverException: java.io.IOException: Output closed` seen on calling devTools.createSession()
What happened?
I am upgrading from selenium 4.13 to 4.16.1 to stay in line with the browser version on my machine (I have no control over the version as its controlled by our organisation).
I am using BiDI/CDP Network Interception and it works alright in 4.13 but does not work in 4.16.1 and ends up giving the above error when devTools.createSession() or .createSessionIfThereIsNotOne() is called.
I am using Cucumber-Java8 as my Test Runner and OpenJDK11.
How can we reproduce the issue?
protected DevTools interceptResponseEndingWith(String urlPrefix) {
log.info("Starting HTTP Response interception...");
DevTools devTools = ((HasDevTools) driver).getDevTools();
devTools.createSessionIfThereIsNotOne();
devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));
final RequestId[] requestId = new RequestId[1];
devTools.addListener(
Network.responseReceived(),
responseConsumer -> {
Response response = responseConsumer.getResponse();
log.info("Intercepted Response--> {}", response.getUrl());
requestId[0] = responseConsumer.getRequestId();
if (response.getUrl().endsWith(urlPrefix)
&& !response.getUrl().contains("www.google-analytics.com")) {
log.info("Filtered Response--> {}", response.getUrl());
log.info("Filtered ResponseId --> {}", requestId[0]);
log.info("Response Status Code --> {}", response.getStatus());
scenarioContext.responseStatusCode = response.getStatus();
scenarioContext.responseBody =
devTools.send(Network.getResponseBody(requestId[0])).getBody();
log.info("Response Body--> {}", scenarioContext.responseBody);
}
});
log.info("Started HTTP Response interception!!");
return devTools;
}
### Relevant log output
```shell
org.openqa.selenium.WebDriverException: java.io.IOException: Output closed
Build info: version: '4.16.1', revision: '9b4c83354e'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.0.1'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:304)
at org.openqa.selenium.remote.http.WebSocket.sendText(WebSocket.java:32)
at org.openqa.selenium.devtools.Connection.send(Connection.java:172)
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:183)
at org.openqa.selenium.devtools.DevTools.findTarget(DevTools.java:171)
at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:131)
at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:117)
at com.jcs.race.steps.BaseSteps.interceptResponseEndingWith(BaseSteps.java:104)
...
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.TransportImpl$SendTask$1.onText(TransportImpl.java:366)
at java.net.http/jdk.internal.net.http.websocket.TransportImpl$SendTask$1.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.TransportImpl$SendTask.run(TransportImpl.java:545)
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.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.JdkHttpClient$5.lambda$send$1(JdkHttpClient.java:271)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.send(JdkHttpClient.java:294)
at org.openqa.selenium.remote.http.WebSocket.sendText(WebSocket.java:32)
at org.openqa.selenium.devtools.Connection.send(Connection.java:172)
at org.openqa.selenium.devtools.Connection.sendAndWait(Connection.java:183)
at org.openqa.selenium.devtools.DevTools.findTarget(DevTools.java:171)
at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:131)
at org.openqa.selenium.devtools.DevTools.createSession(DevTools.java:117)
at com.jcs.race.steps.BaseSteps.interceptResponseEndingWith(BaseSteps.java:104)
Operating System
Windows 10
Selenium version
4.16.1
What are the browser(s) and version(s) where you see this issue?
Edge
What are the browser driver(s) and version(s) where you see this issue?
120.0.2210.91
Are you using Selenium Grid?
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 29 (13 by maintainers)
Sorry,I missed this. Sure, I can help take a look into this.
thatβs a shame π¦ NP, I will wait for it to be available on Edge as well then. Thanks again for your help.
Sorry I couldnβt get back earlier, thanks everyone who helped with this, especially @pujagani. We stopped using BiDi for auth, instead went back to passing
username:password@in the URL and no failure is seen even after upgrading to4.18.1. It looks like its a problem specific to our kerberos server which is causing the Predicate to timeout. When I get some time, I will probably revert back to BiDi auth on the new version of Selenium and get back if I can reproduce the issue.Appreciate your help on this.
sure, will do something like that. I will create new project that will only authenticate using BiDi and intercept network but will retain all libraries I am currently using. If I am able to reproduce the issue, then I will share a runnable project, I will keep you updated.
Thanks.