Specifying outgoing communication port for a "Client"

139 views
Skip to first unread message

mark yoffe

unread,
Sep 23, 2014, 10:32:12 PM9/23/14
to netm...@googlegroups.com
Hi

Does anyone know how to specify an outgoing port for a NetMQ "Client"

I have an application behind various firewalls,

The server binds a Port on the server machine ( we open the fire wall for this side and all is well)

however on the client side , NetMq allows to specify the target Address and Port , but not the port through which the communication will be going through ,
so the firewall blocks this outgoing communication.


client side snippet

using (NetMQContext ctx = NetMQContext.
{
    using (NetMQSocket subscriber = ctx.CreateSocket(ZmqSocketType.Sub))
    {
           subscriber.Connect(SubscriberCommunicationAddress); <<<<---------------- Only has target adress , where can we specify the port to use for outgoing communication
         }



Any help would be appreciated

Thanks

Mark

Rei Roldan

unread,
Sep 24, 2014, 12:33:55 PM9/24/14
to netm...@googlegroups.com
That makes absolutely no sense what so ever... When you initiate a connection, it will be an outbound to the specified address / port, and that is what you configure in your firewall. From client machine X outgoing on port ### (and addr/ip if needed). Unless what you are doing is connecting to something like tcp://ip.addr without specifying the port number, in which case you clearly have not RTFM ;)

mark yoffe

unread,
Sep 25, 2014, 4:29:47 AM9/25/14
to Rei Roldan, netm...@googlegroups.com

Hi Rei

And thanks again for the help.
I might be wrong here but TCP and UDP usually request a free random port from the system when creating an outgoing connection, in c# there is an option to specify that port (foe udp for sure , tcp I'm less sure , this is rarely used but...)
Just to make sure I'm not mistaken here I did run net stat and indeed the local port on the client was 51435 (run it several times and it always grabbed the next port available 51,000 + ) but the destination  port was very different ,

The original issue that led me to this problem has been solved (talked security down from the high tree they climbed) but would still appreciate a feed back.

Is this not supported?  am I missing something ? As I mentioned before I saw this discussed in the past on 0mq forums and I was under the impression a patch was implemented to support this, so I assumed NetMQ would also have it.

Check this forum discussion 0MQ - http://grokbase.com/t/zeromq/zeromq-dev/13a5szhz7h/tcp-source-port

Cheers
Mark

On Sep 25, 2014 12:46 AM, "Rei Roldan" <raro...@gmail.com> wrote:
Hi Mark,

    No worries at all, the thing is, I still don't understand what you mean by "setting the initial port", unless I'm forgetting something about how the TCP stack works, the port you provide in the connect line ie: tcp://localhost:8934, in this case the client will perform an outgoing tcp connection on port 8934 to address localhost. You can easily verify this behavior by using something like tcpview (if on windows), or plain simply netstat.

    Please let us know if you continue to have issues with the library and we'll see if we can further help you out.

(Oh and please reply on the google group, you've sent this message directly to me, doesn't bother me at all, just that more people can benefit if when we sort it out :)

Greetings,
Rei

On 24/09/2014 19:30, mark yoffe wrote:

Hi Rei

Thanks for your help, everything you said is true. And in most cases I encountered it was ,enough to state the outgoing address for the FW.
Sadly for one client with extreme secure system, there was a request to set the initial port used.
It might sound crazy, but I guess I'm not alone, as i saw a thread about it on the 0mq mailing lists a few years back, and I think they might have implemented this feature.

Thanks for the info , I'll just have to convince the security people they are overreacting.

Cheers
Mark


Rei Roldan

unread,
Sep 25, 2014, 4:43:22 AM9/25/14
to netm...@googlegroups.com, raro...@gmail.com
I stand corrected, you can indeed specify the local client port according to the msdn docs: http://msdn.microsoft.com/en-us/library/3bsb3c8f%28v=VS.100%29.aspx 
The proposed format for it on the zmq mailing list appears to be tcp://sourceport;endpoint:port . This shouldn't be much of a problem to implement.

/Rei

mark yoffe

unread,
Sep 25, 2014, 4:47:34 AM9/25/14
to Rei Roldan, netm...@googlegroups.com

Hi Rei

I just verified it and indeed 0MQ latest version support it (implemented in April), NetMQ is not yet there, the minute I'll find a few spare hours I will definitely implement this.

Thanks for taking the time to answer.

Cheers
Mark

--
You received this message because you are subscribed to a topic in the Google Groups "netmq-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/netmq-dev/UBIn-YFJ9B0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to netmq-dev+...@googlegroups.com.
To post to this group, send email to netm...@googlegroups.com.
Visit this group at http://groups.google.com/group/netmq-dev.
For more options, visit https://groups.google.com/d/optout.

Rei Roldan

unread,
Sep 25, 2014, 5:19:47 AM9/25/14
to netm...@googlegroups.com, raro...@gmail.com
If it's not too much to ask, could you please create it as an issue @ https://github.com/zeromq/netmq/issues 

/Rei

Doron Somech

unread,
Sep 25, 2014, 7:36:42 AM9/25/14
to Rei Roldan, netm...@googlegroups.com
mark best is to try to find the commit or commits from zeromq that implement the feature, then link to them here and also as Rei said in the issue you are opening on github.

--
You received this message because you are subscribed to the Google Groups "netmq-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netmq-dev+...@googlegroups.com.

mark yoffe

unread,
Sep 25, 2014, 10:59:05 AM9/25/14
to Doron Somech, Rei Roldan, netm...@googlegroups.com

Thanks Doron, Rei

For completeness here is the link to discussion and commit of the aforementioned issue in 0mq

http://grokbase.com/t/zeromq/zeromq-dev/145476hz80/socket-startpoint

Cheers
Mark

mark yoffe

unread,
Sep 25, 2014, 1:34:24 PM9/25/14
to Doron Somech, Rei Roldan, netm...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages