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

why before response.close() must response.getChannel().deregister()? #609

Open
ahu0605 opened this issue Jun 16, 2018 · 2 comments
Open

Comments

@ahu0605
Copy link

ahu0605 commented Jun 16, 2018

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 ?

@jamesgorman2
Copy link
Collaborator

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

@ahu0605
Copy link
Author

ahu0605 commented Jun 17, 2018

oh,I just run the demo the client is http client get a request ,then the server happen exception

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