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

java.net.SocketException: Connection or outbound has been closed #3692

Open
SamratDawn opened this issue Sep 16, 2024 · 1 comment
Open

java.net.SocketException: Connection or outbound has been closed #3692

SamratDawn opened this issue Sep 16, 2024 · 1 comment

Comments

@SamratDawn
Copy link

SamratDawn commented Sep 16, 2024

I am trying to create a exec request using this page as reference but sometimes when I am running the code I am getting this error-

java.net.SocketException: Connection or outbound has been closed
at java.base/sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:291)
at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1298)
at okio.OutputStreamSink.write(JvmOkio.kt:56)
at okio.AsyncTimeout$sink$1.write(AsyncTimeout.kt:102)
at okio.RealBufferedSink.flush(RealBufferedSink.kt:268)
at okhttp3.internal.ws.WebSocketWriter.writeControlFrame(WebSocketWriter.kt:142)
at okhttp3.internal.ws.WebSocketWriter.writeClose(WebSocketWriter.kt:102)
at okhttp3.internal.ws.RealWebSocket.writeOneFrame$okhttp(RealWebSocket.kt:533)
at okhttp3.internal.ws.RealWebSocket$WriterTask.runOnce(RealWebSocket.kt:620)
at okhttp3.internal.concurrent.TaskRunner.runTask(TaskRunner.kt:116)
at okhttp3.internal.concurrent.TaskRunner.access$runTask(TaskRunner.kt:42)
at okhttp3.internal.concurrent.TaskRunner$runnable$1.run(TaskRunner.kt:65)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

I have tried extending the timeouts and separating the in, out, err streams but nothing works.
I saw the issue 3385 but how do I fix the error in my code?

Version used - 21.0.0

@brendandburns
Copy link
Contributor

brendandburns commented Sep 16, 2024

As mentioned here: #3385 (comment)

You need to set the exception handler on the Exec class, you can then suppress the logging of the exception if you want to.

What is happening is that both sides of the connection are attempting to close the connection when the exec completes and there is a race. Sometimes the server side wins and the client gets this exception when trying to close the web socket, because the tcp socket is already closed.

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

No branches or pull requests

2 participants