简体   繁体   中英

MalformedChunkCodingException: Chunked stream ended unexpectedly

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?

导致此异常的原因实际上是haproxy,它在空闲时间过长时关闭了套接字。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM