question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EOFException on websocket

See original GitHub issue

After connecting to webservice every single minute (seems like some ping) I’m getting the below exception (which forces me to reconnect).

java.io.EOFException
         at okio.RealBufferedSource.require(RealBufferedSource.java:59)
         at okio.RealBufferedSource.readByte(RealBufferedSource.java:72)
         at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.java:113)
         at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:97)
         at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:261)
         at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:200)
         at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
         at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
         at java.lang.Thread.run(Thread.java:818)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

13reactions
roman-upnextcommented, Jan 16, 2017

@swankjesse you were right, after 60s of inactivity the server was closing the socket. The solution for this is of course setting a ping interval on OkHttpClient:

.pingInterval(30, TimeUnit.SECONDS)
10reactions
DavidSerrcommented, Feb 1, 2017

@swankjesse I have the same problem as @roman-upnext but at the time to close the socket. I trigger the close method webSocket.close(1000, null); as in WebSocketEcho example and I always receive back the EOFException through onFailure method from listener public void onFailure(WebSocket webSocket, Throwable t, Response response)

Exception:

java.io.EOFException
at okio.RealBufferedSource.require(RealBufferedSource.java:59)
at okio.RealBufferedSource.readByte(RealBufferedSource.java:72)
at okhttp3.internal.ws.WebSocketReader.readHeader(WebSocketReader.java:113)
at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.java:97)
at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.java:262)
at okhttp3.internal.ws.RealWebSocket$2.onResponse(RealWebSocket.java:201)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Tomcat: EOFException when trying to reconnect via Websockets
I have a problem using ktor websockets, I had two different client types: Android: The connection to websocket it's ok, I can send...
Read more >
java.io.EOFException when using WebSocket - Google Groups
Hi all,. I'm using server-to-server WebSocket connections to link clients to a cometd event pipeline. All goes well for a while, but the...
Read more >
[Solved]-Spring websocket EOFException-Springboot
I was getting mysterious EOFExceptions when user sessions ended, and my solution was to beef up error handling (use a more detailed onError...
Read more >
Intermittent connection to? - Dremio Community
server.socket.SocketServlet - Failure in web socket handling. java.io.EOFException: Disconnected at org.eclipse.jetty.websocket.common.
Read more >
Spring-boot – Spring websocket EOFException - iTecNote
Yup, i solved it. This exception will happen after client or server was interrupted or stopped without calling close socket method(maybe lost internet,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found