W mojej klasie (rozszerza SimpleChannelHandler) Próbuję uzyskać adres IP, z którego wiadomość została pierwotnie wysłana.Netty: pobieranie zdalnego adresu IP w wiadomości Odebrano
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent ev) throws Exception {
String host = ((InetSocketAddress)ctx.getChannel().getRemoteAddress()).getAddress().getHostAddress();
int port = ((InetSocketAddress)ctx.getChannel().getRemoteAddress()).getPort();
LOG.debug(String.format("host:%s port:%d", host, port));
..
To drukuje ip 10.0.0.1 (brama), zamiast poprawnego adresu klienta (10.52.45.4).
Czy istnieje sposób, aby uzyskać IP próbuję lub może być coś nie tak z konfiguracją sieci?
Wystarczy niewielka aktualizacja w składni nowszej netty 4.1.5 '((InetSocketAddress) ctx.channel(). remoteAddress()). getAddress(). getHostAddress();' – Aaron