Hi, Alex

10.02.16 19:23, Alex Bligh пишет:
> I am investigating building a zeromq-based application which runs over TCP. 
> It will run many separate services over zeromq, mostly REP/REQ (via proxies), 
> but also PUB/SUB.
>
> The normal way to do this as far as I can tell is to use one TCP port per 
> service. I want to avoid doing this, as the services can be dynamically 
> created and deleted and I don't want to be bothered with different firewall 
> rules, port management etc.
Have you considered random port binding? You can specify ports range so 
that makes easier to configure the firewall. You will need some kind of 
a directory service (Redis is mostly used) to tell the clients (who 
connects) about the running services and their ports. The benefit of 
this approach is that you are not limited by only one host (in case of 
IPC you are) but can scale your services to any number of hosts.
>
> For inproc communication that's fine, as I can specify a unique name. 
> However, the TCP endpoint does not have this. Only one socket can bind to a 
> tcp port.
>
> What I'd really like to do is simply to multiplex (by service name) multiple 
> services (i.e. multiple sockets) onto the same TCP port. They would then pass 
> like shadows in the night. I would like this to transparently work with 
> encryption too.
>
> I think this would be no harder than adding an additional frame (the service 
> name) on send, and stripping it on receive. However, I can't immediately see 
> how to do this using standard Router / Dealer code (partly because I'd have 
> to somehow route the messages to the correct endpoints that had 'connected'), 
> though I may be missing something. In many ways it would seem to be easier to 
> modify the endpoint protocol.
>
> Am I missing something? Am I approaching this the right way?
>
The solution here is to have some kind of a proxy process which binds to 
a TCP port and then redirects messages to the target services by IPC 
(You can have the same in a thread and use INPROC as well). zmq_proxy 
device exists for such reason.

Thanks,
Oleksii
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to