开发者

event get to the wrong NIO Worker

i am running a client-router-server scenaqrio with UDP protocol with Netty (3.2.3 version)

i see that the client and server channels are reg开发者_如何学Goistered fine with the NIO workers , but the response that comes back from the server is being assigned to the wrong Worker , (NIODatagramWorker) so it is a different Selector and the message get to the wrong pipeline (as if it came from the Client) .

please advise, Yair


Netty UDP is a bit tricky. UDP only has one pipeline actually, so if you change the selector, or handlers within the pipeline it may not have desired affect. Take a look at this UDP Woes link in the Netty user group which has Trustin Lee's explanation of this behavior.

So your general case while using UDP will be
1) create a single pipeline factory and pipeline with your decoders and encoders.
2) Use a hashmap or similar data structure to lookup and route the incoming data to the correct session you are having.
3) When you write back, use write(data,remoteSocketAddress) method instead of normal write method of channel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜