什么时候使用keepalive调用channelInactive? [英] When is channelInactive called with keepalive on?

查看:1601
本文介绍了什么时候使用keepalive调用channelInactive?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处理一些http请求的SimpleChannelInboundHandler:

I have a SimpleChannelInboundHandler which handles a few http requests:

CacheServerHandler extends SimpleChannelInboundHandler<FullHttpRequest>

当我没有明确关闭频道/连接并且keepalive为true时,每次都会调用channelInactive在channelRead0完成后?

When i do not explicitly close the channel/connection and keepalive is true, will channelInactive be called every time after channelRead0 is done?

或者当频道/连接关闭时,只会调用一次channelInactive吗?

Or will channelInactive only be called once when the channel/connection is closed?

我问这个是因为当http连接上的keepalive为true时,客户端不会关闭连接,客户端可以在不打开/关闭连接的情况下发送多个请求。

I ask this because when keepalive is true on a http connection the connection isn't closed by client and client can send multiple requests without opening/closing the connection.

推荐答案

只有在关闭频道时才会调用ChannelInactive()。这是合同。

ChannelInactive() will only be called when the channel is closed. This is the contract.

这篇关于什么时候使用keepalive调用channelInactive?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆