मेरी कक्षा में (सरल चैनेल हैंडलर बढ़ाता है) मैं आईपी प्राप्त करने की कोशिश कर रहा हूं जहां संदेश मूल रूप से भेजा गया था।नेटटी: संदेश में रिमोट आईपी पता प्राप्त करना
@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));
..
यह सही क्लाइंट पता (10.52.45.4) के बजाय आईपी 10.0.0.1 (गेटवे) प्रिंट करता है।
क्या आईपी प्राप्त करने का कोई तरीका है या मैं नेटवर्क कॉन्फ़िगरेशन में कुछ गलत कर सकता हूं?
नई नेटटी 4.1.5 '((इनसेट सॉकेट एड्रेस) ctx.channel()। दूरस्थ एड्रेस()) के साथ वाक्यविन्यास में बस थोड़ा सा अपडेट। getAddress()। getHostAddress();' – Aaron