-
Notifications
You must be signed in to change notification settings - Fork 13
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
SimpleChannelInboundHandler<DatagramPacket> added in the pipeline does not work #11
Comments
No. Thats literally a part of the readme about channel per remote address and using channel remote address for that. |
Thanks for the quick reply! I would like to explain the scenario which I am trying to solve. The UDP server which uses your library is behind a load balancer. So, the channel remote address is the ip address of the Load Balancer. But, I have to obtain the IP address of the client which sent the request. I noticed that p.sender() is used for computation in
But, for removal , channel's remoteAddress is used.
If the UDP server is behind a Load Balancer, p.sender() and userChannel.remoteAddress() will be different as per my understanding. p.sender() will be the IP address of the client which sent the request. userChannel.remoteAddress() will be the IP address of the Load balancer. Please correct me if I am wrong. |
The user channel remote address is literally the datagram sender address. So they will always the the same. That's literally the whole point of this library, every new sender address allocates a new user channel. The load balancer you use proxies the remote address using it's own protocol if it ever does. |
Ok Thanks a lot! Let me test the use-case with Load balancer and get back if needed. |
There is a requirement in my project to obtain Host Address of the sender from the UDP Header for processing the request. As per my understanding, I need to add a handler using which I will get DatagramPacket. So, I modified the usage example given in https://github.com/Shevchik/UdpServerSocketChannel by replacing:
private static class Echo extends SimpleChannelInboundHandler
with
public static class Echo extends SimpleChannelInboundHandler.
The modified example is attached.
But, protected void channelRead0(ChannelHandlerContext channelHandlerContext, DatagramPacket datagramPacket) throws Exception is not invoked at all. It may be because the library (UdpServerSocketChannel) already has a similar handler
UdpServerSocketChannel/src/udpserversocketchannel/channel/UdpServerChannel.java
Line 61 in a181129
protected class ReadRouteChannelHandler extends SimpleChannelInboundHandler {
Can you please let me know if the above solution which I am trying can be made to work? If not, please let me know any alternate solution which I can try.
Thanks!
ExampleUdpServer.txt
The text was updated successfully, but these errors were encountered: