[nanomsg] Re: A multiple client/worker for NN_PAIR style sockets.

  • From: Rohit Saboo <saboo.rohit@xxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Wed, 7 Jan 2015 15:13:25 -0800

Hi Alex,

Thanks for helping out. See comments inline.

@Garret, doesn't NN_BUS send the messages to everyone. It can address
client-to-server communication. However, how will the server address a
message to a specific client?

Rohit

On Wed, Jan 7, 2015 at 2:28 PM, Alex Elsayed <eternaleye@xxxxxxxxx> wrote:

> Honestly, this sounds like a misdesign - the semantics you want are TCP
> semantics, and you'd basically only be using nanomsg as framing.
>
> People use ZMQ that way, but it was explicitly left out of the intended
> usecases of nanomsg if I remember correctly.
>
> It may be best to decompose your protocol into multiple parts. Could you
> give more information on what _actually_ gets sent back and forth? I'd be
> willing to help.
>
> Nanomsg is designed around "patterns" - higher-level communication
> primitives - _instead_ of application-level free messages.
>
> Here are some that might be useful for your case:
> Messages that need a response, but only from one peer: REQ/REP
> Messages that need a response from the set of peers: SURVEY
> One-way messages to all: PUB/SUB
> One-way messages to one peer: PUSH/PULL
>

The "application" is composed of "two" parts -- a set of clients and a
server. The server will be replicated for load balancing and handling
failovers. All communication between the clients and servers is expected to
be authenticated and secure for which I've separate application-level
logic. The communication between them will fall into one of these patterns:
* client sends updates to server (at a frequency greater than 20Hz),
expecting no response from the server;
* client asks questions to server expecting a response;
* server sends updates to all clients;
* server sends updates to a specific client; or
* server asks questions to a specific client expecting a response.


> Also, them being on different networks isn't _that_ tricky - you can use
> nn_device to create a sort of bridging point.
>
>
Take the following example:
Client Ci is in network Ni with gateway Gi connecting it to the public
internet. A server S0 is in network N0 with gateway G0. Now G0's ip is
well-known, and it can be configured to forward connections on specific
ports to S0. However, Gi are not in our control and the binary with
nn_device would have to run on Gi, right?


> > Hi all,
> >
> > I need to create a system where there are several clients that can
> > communicate simultaneously with a server. For simplicity, we can assume
> > that the server has a constant number of workers.
> >
> > The clients can send messages to the servers and the workers may respond
> > to these messages and/or send messages by itself possibly expecting
> > responses. In other words, there's free two way communication between a
> > client and the server.
> >
> > Using NN_PAIR with devices results in the error "transport endpoint
> > already connected" when the second worker tries to connect to the local
> > "inproc" socket. Using a solution that creates a pair of NN_PUSH/NN_PULL
> > sockets also won't work because the client and server are on different
> > networks and providing a connection endpoint on the client for the server
> > to connect to will be tricky.
> >
> > Is there a way in nanomsg to have free two-way communication between
> > multiple clients and a single server?
> >
> > Thanks,
> > Rohit
>
>
>
>

Other related posts: