How can a Netty server cancel receiving a response

2019-04-15 03:26发布

问题:

Does anyone know the best way for a netty server handler to cancel receiving data from a web server? I have a server handler which proxies HttpRequests to a web server. However, when the requesting client cancels the request, I would like to stop receiving data on my server channel from the web server without closing the connection between the server handler and the web server.

Does anyone know how I can go about doing this. Your response would be much appreciated.

Thank you!

回答1:

You could call channel.config().setAutoRead(false) this will tell netty to stop reading from the Channel. Once you want to start reading again just call channel.config().setAutoRead(false).