Re: [zeromq-dev] Multiplexing a TCP endpoint

2016-02-15 Thread Pieter Hintjens
The design is neat. Sadly too much work to implement it in libzmq, and
more profitable areas to work on.

On Mon, Feb 15, 2016 at 12:33 PM, Tom Quarendon
 wrote:
> The idea with resources would be that when you connected or bound, you just 
> added the resource name after the endpoint, as in:
> connect("tcp://localhost:/resource")
>
> Has the great advantage that it is completely encapsulated in the endpoint 
> string, so any existing code that uses ZeroMQ, any protocol that might be 
> implemented can trivially be made to run over a "multiplexed" port, you just 
> change the endpoint string.
>
> Adding the information as an extra frame means you start needing to alter 
> your protocol logic, and you need to be aware of what framing your protocol 
> might use. If your protocol already used multiple frames per message then you 
> have the issue of finding the "service routing" frame.
>
> Search for "ZMTP 3.0 "Resources". Implemented?"
>
> -Original Message-
> From: zeromq-dev-boun...@lists.zeromq.org 
> [mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Alex Bligh
> Sent: 11 February 2016 12:22
> To: ZeroMQ development list 
> Cc: Alex Bligh 
> Subject: Re: [zeromq-dev] Multiplexing a TCP endpoint
>
>
> On 10 Feb 2016, at 19:11, Tom Quarendon  wrote:
>
>> This is what "resources" in ZMTP 3.1 were designed for. No implementation 
>> yet though (see other discussion on his list) :-)
>
> Thanks. That is pretty much exactly what I was looking for (other than the 
> 'no implementation yet though' bit).
>
> I've only just subscribed to the list and my google search through the 
> archives led only to a post in 2013 hoping this would be in zeromq 4.0. Do 
> you have a pointer to the discussion (e.g. the thread title)?
>
> I've read the relevant part of the ZTMP specification. In essence the 
> 'resource' seems to be transmitted in the metadata when the connection is set 
> up. I'm guessing to use this feature in a compatible way without 
> implementation details, then:
>
> 1. On the 'connect' side, I'd merely need to add some metadata
>
> 2. On the 'bind' side, I'd need to run some form of multiplexer and look at 
> the metadata property.
>
> I can't however see an API way to set or read from the metadata dictionary 
> before any messages are passed.
>
> Am I therefore correct that it isn't possible to implement this without a 
> change to zeromq itself?
>
>> You would have to write the proxy loop yourself. So do a select on the 
>> external socket and all the internal sockets and know that when you pull a 
>> message from the external socket that you peel off the first frame after the 
>> delimiter, then use the service name it includes to pick which internal 
>> socket to pass the rest of the message to. The services then run 
>> independently on their own inproc (or even out of process on ipc or tcp) 
>> sockets. It's what I would end up doing to do the same thing.
>
> That's pretty much what I concluded save for the fact that I had thought the 
> service ID should probably be the innermost frame (possibly after the empty 
> frame delimiter and with it's own zero frame delimiter) so the transport over 
> TCP could (if necessary) be routed transparently through RTR sockets.
>
> --
> Alex Bligh
>
>
>
>
> ___
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> ___
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] Multiplexing a TCP endpoint

2016-02-15 Thread Tom Quarendon
The idea with resources would be that when you connected or bound, you just 
added the resource name after the endpoint, as in:
connect("tcp://localhost:/resource")

Has the great advantage that it is completely encapsulated in the endpoint 
string, so any existing code that uses ZeroMQ, any protocol that might be 
implemented can trivially be made to run over a "multiplexed" port, you just 
change the endpoint string.

Adding the information as an extra frame means you start needing to alter your 
protocol logic, and you need to be aware of what framing your protocol might 
use. If your protocol already used multiple frames per message then you have 
the issue of finding the "service routing" frame. 

Search for "ZMTP 3.0 "Resources". Implemented?"

-Original Message-
From: zeromq-dev-boun...@lists.zeromq.org 
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Alex Bligh
Sent: 11 February 2016 12:22
To: ZeroMQ development list 
Cc: Alex Bligh 
Subject: Re: [zeromq-dev] Multiplexing a TCP endpoint


On 10 Feb 2016, at 19:11, Tom Quarendon  wrote:

> This is what "resources" in ZMTP 3.1 were designed for. No implementation yet 
> though (see other discussion on his list) :-)

Thanks. That is pretty much exactly what I was looking for (other than the 'no 
implementation yet though' bit).

I've only just subscribed to the list and my google search through the archives 
led only to a post in 2013 hoping this would be in zeromq 4.0. Do you have a 
pointer to the discussion (e.g. the thread title)?

I've read the relevant part of the ZTMP specification. In essence the 
'resource' seems to be transmitted in the metadata when the connection is set 
up. I'm guessing to use this feature in a compatible way without implementation 
details, then:

1. On the 'connect' side, I'd merely need to add some metadata

2. On the 'bind' side, I'd need to run some form of multiplexer and look at the 
metadata property.

I can't however see an API way to set or read from the metadata dictionary 
before any messages are passed.

Am I therefore correct that it isn't possible to implement this without a 
change to zeromq itself?

> You would have to write the proxy loop yourself. So do a select on the 
> external socket and all the internal sockets and know that when you pull a 
> message from the external socket that you peel off the first frame after the 
> delimiter, then use the service name it includes to pick which internal 
> socket to pass the rest of the message to. The services then run 
> independently on their own inproc (or even out of process on ipc or tcp) 
> sockets. It's what I would end up doing to do the same thing. 

That's pretty much what I concluded save for the fact that I had thought the 
service ID should probably be the innermost frame (possibly after the empty 
frame delimiter and with it's own zero frame delimiter) so the transport over 
TCP could (if necessary) be routed transparently through RTR sockets.

-- 
Alex Bligh




___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] Multiplexing a TCP endpoint

2016-02-11 Thread Alex Bligh

On 10 Feb 2016, at 19:11, Tom Quarendon  wrote:

> This is what "resources" in ZMTP 3.1 were designed for. No implementation yet 
> though (see other discussion on his list) :-)

Thanks. That is pretty much exactly what I was looking for (other than the 'no 
implementation yet though' bit).

I've only just subscribed to the list and my google search through the archives 
led only to a post in 2013 hoping this would be in zeromq 4.0. Do you have a 
pointer to the discussion (e.g. the thread title)?

I've read the relevant part of the ZTMP specification. In essence the 
'resource' seems to be transmitted in the metadata when the connection is set 
up. I'm guessing to use this feature in a compatible way without implementation 
details, then:

1. On the 'connect' side, I'd merely need to add some metadata

2. On the 'bind' side, I'd need to run some form of multiplexer and look at the 
metadata property.

I can't however see an API way to set or read from the metadata dictionary 
before any messages are passed.

Am I therefore correct that it isn't possible to implement this without a 
change to zeromq itself?

> You would have to write the proxy loop yourself. So do a select on the 
> external socket and all the internal sockets and know that when you pull a 
> message from the external socket that you peel off the first frame after the 
> delimiter, then use the service name it includes to pick which internal 
> socket to pass the rest of the message to. The services then run 
> independently on their own inproc (or even out of process on ipc or tcp) 
> sockets. It's what I would end up doing to do the same thing. 

That's pretty much what I concluded save for the fact that I had thought the 
service ID should probably be the innermost frame (possibly after the empty 
frame delimiter and with it's own zero frame delimiter) so the transport over 
TCP could (if necessary) be routed transparently through RTR sockets.

-- 
Alex Bligh




___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] Multiplexing a TCP endpoint

2016-02-10 Thread Michal Vyskocil
Hi,

In case you want to play even more, there is malamute broker. It can listen
in tcp socket and you can filter incoming messages per stream or subject.

The disadvantage is you must use mlm client API to make it work. However
sounds like right tool for your use case.
Dne 10. 2. 2016 8:12 PM napsal uživatel "Tom Quarendon" <
tom.quaren...@teamwpc.co.uk>:

> This is what "resources" in ZMTP 3.1 were designed for. No implementation
> yet though (see other discussion on his list) :-)
>
> You would have to write the proxy loop yourself. So do a select on the
> external socket and all the internal sockets and know that when you pull a
> message from the external socket that you peel off the first frame after
> the delimiter, then use the service name it includes to pick which internal
> socket to pass the rest of the message to. The services then run
> independently on their own inproc (or even out of process on ipc or tcp)
> sockets. It's what I would end up doing to do the same thing.
>
> Hope that helps.
>
> -Original Message-
> From: zeromq-dev-boun...@lists.zeromq.org [mailto:
> zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Alex Bligh
> Sent: 10 February 2016 17:24
> To: zeromq-dev@lists.zeromq.org
> Cc: Alex Bligh 
> Subject: [zeromq-dev] Multiplexing a TCP endpoint
>
> 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.
>
> 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?
>
> --
> Alex Bligh
>
>
>
>
> ___
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> ___
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] Multiplexing a TCP endpoint

2016-02-10 Thread Tom Quarendon
This is what "resources" in ZMTP 3.1 were designed for. No implementation yet 
though (see other discussion on his list) :-)

You would have to write the proxy loop yourself. So do a select on the external 
socket and all the internal sockets and know that when you pull a message from 
the external socket that you peel off the first frame after the delimiter, then 
use the service name it includes to pick which internal socket to pass the rest 
of the message to. The services then run independently on their own inproc (or 
even out of process on ipc or tcp) sockets. It's what I would end up doing to 
do the same thing. 

Hope that helps.

-Original Message-
From: zeromq-dev-boun...@lists.zeromq.org 
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Alex Bligh
Sent: 10 February 2016 17:24
To: zeromq-dev@lists.zeromq.org
Cc: Alex Bligh 
Subject: [zeromq-dev] Multiplexing a TCP endpoint

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.

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?

-- 
Alex Bligh




___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] Multiplexing a TCP endpoint

2016-02-10 Thread ozamiatin
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


[zeromq-dev] Multiplexing a TCP endpoint

2016-02-10 Thread 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.

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?

-- 
Alex Bligh




___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev