why before response.close() must response.getChannel().deregister()?
if I do not excute response.getChannel().deregister() ,the server will throws IOExcption : An existing connection was forcibly closed by the remote host ? why???? the http client code has some mistake ?
Are you fronting this with a proxy? We have a similar problem where HAProxy force closes the connection with RST and Netty returns a IOException when it tries to FIN the already closed connection. Ours reports as either this or Connection reset by peer. If it's something similar to this, it is because Netty is unopinionated about handling rude connection closes and forces the errors down into the handlers. My guess is they don't want to accidentally clobber any important unexpected behaviour.
Your best bet is to add
.catch(
e -> {
if (
e instanceOf IOException &&
"An existing connection was forcibly closed by the remote host.".equals(e.getMessage())
) {
return Observable.empty();
} else {
return Observable.throw(e);
}
}
)
to your observable.
cf, https://stackoverflow.com/questions/21550337/haproxy-netty-way-to-prevent-exceptions-on-connection-reset
oh,I just run the demo the client is http client get a request ,then the server happen exception