문제

Enter code here I've implemented an SSE server and client. The server is implemented using Netty and the client uses Apache http client.

If I send a message at least every 30 seconds it all seems to work fine, but if I do not I will intermittently get this exception:

```
 Caused by: org.apache.http.MalformedChunkCodingException: Chunked stream ended unexpectedly
    W/System.err( 2879):    at org.apache.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:222)
    W/System.err( 2879):    at org.apache.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:183)
    W/System.err( 2879):    at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:155)
    W/System.err( 2879):    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:159)
    W/System.err( 2879):    at java.io.InputStreamReader.read(InputStreamReader.java:244)
    W/System.err( 2879):    at java.io.BufferedReader.fillBuf(BufferedReader.java:130)
    W/System.err( 2879):    at java.io.BufferedReader.readLine(BufferedReader.java:354)
    W/System.err( 2879):    at com.clover.engine.push.SSEConnection$1.call(SSEConnection.java:85)
    W/System.err( 2879):    at com.clover.engine.push.SSEConnection$1.call(SSEConnection.java:79)
    W/System.err( 2879):    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
```

Right now I'm sending a keep alive message every 30 seconds, but I'd prefer to not have to.

Any suggestions on how to prevent this exception from occurring?

도움이 되었습니까?

해결책

The cause of this exception was actually haproxy which was closing the socket when it was idle for too long.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top