0

i'm using communication based on ZeroMq and NetMQ (same problem in both projects)

I have applications running behind fire walls,

on the server side its easy to define which ports to open for inbound traffic,

however on the client side it seems that i am able only to specify the target (a.k.a server) address and port.

Is it possible to define which port will be used for outbound traffic on the client app.

for example (in NetMQ)

      using (NetMQContext ctx = NetMQContext.Create())
      {
         using (NetMQSocket snapshot = ctx.CreateSocket(ZmqSocketType.Dealer))
         {
           // connect to remote address, no place to specify outbound port
           snapshot.Connect("192.168.1.10:5555");   
         }
      }

In a simple communication scenario we have a Server and a Client

server is running on machine A (192.168.1.10) - and listening on port 5555

Client is running on machine B (192.168.1.9) - and is initiating communication to server (A)

if we look at the communication info on the client we would see that the system allocated port XXXXX (for example 51234) and its outbound to 192.168.1.10:5555

in most cases the XXXXX port is allocated by the system ( a free port), however in some extreme cases the XXXXX port needs to be a specific port (due to extreme security environment)

Curious Guy
  • 113
  • 1
  • 5
  • 1
    ?? The same port, 5555, is used for comms on the dealer socket from client to server.If that's not the answer, you'll need to refine the question. – John Jefferies Sep 24 '14 at 12:11
  • Can you explain the problem you're having? To elaborate on what @JohnJefferies is saying, think of your server as one room and your client as an adjacent room, and you're saying "it's easy tell people coming into the server room to come in this door, but when I'm leaving the client room, how do I choose which door to go through?" It's the same door on both sides of the wall. – Jason Sep 24 '14 at 19:03
  • i added some more explanation, hope this clears the situation – Curious Guy Sep 24 '14 at 19:47
  • @jason - your analogy is good and correct but is not exact, if i was trying to use your analogy , then think of a client room with two doors leading to a hallway at the end of the hallway there is a server room, how can i tell the client to always use door A for the initial trip – Curious Guy Sep 24 '14 at 19:47
  • You're right, I've never concerned myself with the local port, it's an edge case I've never come across. I did find some information which might serve as the closest thing you can get to an answer, I'll post it below. – Jason Sep 24 '14 at 20:35

2 Answers2

2

As you state in your update, the source port is usually allocated by the system. I did find some ZMQ specific communication on the matter:

In this link there is some discussion of how a source IP and source port might be specified in the ZMQ protocol - the people talking here are the core dev team maintaining ZMQ (in particular, Pieter Hintjens "founded" ZMQ), so you can take from this that it was not implemented as of a year ago.

Further, here you can see it was eventually implemented in April of this year... so so long as you have a recent version of ZMQ, and your binding doesn't have any peculiarities that would block this functionality, you should be able to do it if you follow those guidelines.

In particular, it would look something like the following:

snapshot.Connect("192.168.1.9:51234;192.168.1.10:5555");

Again, this may or may not be altered by your binding.

Jason
  • 13,606
  • 2
  • 29
  • 40
  • Thanks . i saw the discussion and even found the patch , but couldn't get it to work, must have been using an old version. Thanks – Curious Guy Sep 25 '14 at 08:39
0

this is not supported in NetMQ, if you want you can try and port the feature from zeromq, it shouldn't be complicated and I can help you.

somdoron
  • 4,653
  • 2
  • 16
  • 24
  • Sadly i can accept only one answer. But i was asking about two systems so your answer for NetMQ is correct. The projects involved have changed fire wall policy to support the normal use case so the problem seems solved for now. I will take you on your offer the minute i have a spare few hours. – Curious Guy Sep 25 '14 at 08:35