You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by SteveR <sr...@vonage.com> on 2015/12/12 02:44:16 UTC

How to specify the UDP source port with camel-netty4 ?

With *Camel 2.16.0* and the *camel-netty4* component, I need to send a UDP
response back to the associated client and I need control over the source IP
(i.e. my local host name) *AND *the UDP source port (i.e. a port number of
my choosing).

Currently, it appears that *camel-netty4* uses the local host IP for the
source IP, but allows the OS choose an ephemeral port number for the
sender's UDP source port.  The UDP client I send the response to expects the
UDP source port be a well-known value (e.g. 12345), for validation purposes.

For example, I have Camel route that consumes exchanges from
*MY_SEDA_QUEUE*, invokes a processor to formulate the UDP response, and
sends it via *netty4:udp* to the associated UDP client specified in the
*CamelNettyRemoteAddress* header of the exchange's input message:

   
from("seda:MY_SEDA_QUEUE?size=1000&concurrentConsumers=25&timeout=10000")
        .process(MyUdpResponseProcessor)
        .toD("netty4:udp:/${header.CamelNettyRemoteAddress}?
                clientPipelineFactory=#MY_CLIENT_PIPELINE_FACTORY&
               
sync=false&disconnect=false&sendBufferSize=26214400&allowDefaultCodec=false");

Any thoughts on how to achieve this is much appreciated.



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-specify-the-UDP-source-port-with-camel-netty4-tp5775017.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to specify the UDP source port with camel-netty4 ?

Posted by SteveR <sr...@vonage.com>.
I'm using *Camel-2.16* and I'm looking at the GitHub code for the 
NettyProducer.java
<https://github.com/apache/camel/blob/camel-2.16.x/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java> 
, and I think the below highlighted code is what causes netty to specify
using an ephemeral port for the UDP source port when the camel-netty4
*udpConnectionlessSending* option is set to *true*.  It would be nice if it
wasn't hard-coded and let you specify a UDP source port of your choosing!
I'm hoping someone with more knowledge will chime in.

            // if udp connectionless sending is true we don't do a connect.
            // we just send on the channel created with bind which means
            // really fire and forget. You wont get an
PortUnreachableException
            // if no one is listen on the port
            if (!configuration.isUdpConnectionlessSending()) {
                answer = connectionlessClientBootstrap.connect(new
InetSocketAddress(configuration.getHost(), configuration.getPort()));
            } else {
                *// bind and store channel so we can close it when stopping
                answer = connectionlessClientBootstrap.bind(new
InetSocketAddress(0)).sync();*
                Channel channel = answer.channel();
                allChannels.add(channel);
            }



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-specify-the-UDP-source-port-with-camel-netty4-tp5775017p5775061.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to specify the UDP source port with camel-netty4 ?

Posted by SteveR <sr...@vonage.com>.
Hi Greg:

Thanks for the reply. However, it's the UDP source port that I'd like
control over.  The *${header.CamelNettyRemoteAddress}* correctly resolves to
the in-flight destination *IP:port *of the client that I need to send the
UDP acknowledgement to.  My problem is that *camel-netty4* is not giving me
control over the UDP source port, instead it appears to be binding to a
local ephemeral port chosen by the Linux OS.

*
SOURCE  IP*         Set correctly to the local IP address of the server
sending the UDP ack
*SOURCE  PORT*    OS ephemeral port (I need to be able to specify this port
number)
*DEST       IP*         Correctly taken from in-flight exchange
CamelNettyRemoteAddress header.
*DEST      PORT*     Correctly taken from in-flight exchange
CamelNettyRemoteAddress header.

So my UDP acknowledgements get delivered to the intended client, but the
client rejects them because
it's examining the UDP source port and seeing that it's not the expected
value, but rather a different ephemeral source port in each acknowledgement.






--
View this message in context: http://camel.465427.n5.nabble.com/How-to-specify-the-UDP-source-port-with-camel-netty4-tp5775017p5775057.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to specify the UDP source port with camel-netty4 ?

Posted by Greg Autric <ga...@redhat.com>.
Hi Steve,

Have you ever tried this syntax ?

"netty4:udp://${header.CamelNettyRemoteAddress}:
${header.CamelNettyRemotePort}?
clientPipelineFactory=#MY_CLIENT_PIPELINE_FACTORY&
sync=false&disconnect=false&sendBufferSize=26214400&allowDefaultCodec=false"

-- 
Greg A
Red Hat

Le vendredi 11 décembre 2015 à 18:44 -0700, SteveR a écrit :
> With *Camel 2.16.0* and the *camel-netty4* component, I need to send a UDP
> response back to the associated client and I need control over the source IP
> (i.e. my local host name) *AND *the UDP source port (i.e. a port number of
> my choosing).
> 
> Currently, it appears that *camel-netty4* uses the local host IP for the
> source IP, but allows the OS choose an ephemeral port number for the
> sender's UDP source port.  The UDP client I send the response to expects the
> UDP source port be a well-known value (e.g. 12345), for validation purposes.
> 
> For example, I have Camel route that consumes exchanges from
> *MY_SEDA_QUEUE*, invokes a processor to formulate the UDP response, and
> sends it via *netty4:udp* to the associated UDP client specified in the
> *CamelNettyRemoteAddress* header of the exchange's input message:
> 
>    
> from("seda:MY_SEDA_QUEUE?size=1000&concurrentConsumers=25&timeout=10000")
>         .process(MyUdpResponseProcessor)
>         .toD("netty4:udp:/${header.CamelNettyRemoteAddress}?
>                 clientPipelineFactory=#MY_CLIENT_PIPELINE_FACTORY&
>                
> sync=false&disconnect=false&sendBufferSize=26214400&allowDefaultCodec=false");
> 
> Any thoughts on how to achieve this is much appreciated.
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-specify-the-UDP-source-port-with-camel-netty4-tp5775017.html
> Sent from the Camel - Users mailing list archive at Nabble.com.