Re: [zeromq-dev] Connection refused error exclusively in Dockerized app

2014-12-29 Thread Dmitri Toubelis
> I have a dockerized ZMQ instance where I am trying to develop an app.
> I have duplicate source both inside the docker instance and at the
> host level. I can compile both inside and out with duplicate
> compiler output and both compile.

> The problem is, there has to be some difference between the docker
> ubuntu instance and the host, because when I run the docker ubuntu
> instance, I get an error at runtime with my unit tests:

> terminate called after throwing an instance of 'zmq::error_t'
> what(): Connection refused

> But the unit tests run to completion on the host.
> I've debugged it, and put print statements, and I know for certain
> that the docker instance is failing at a socket connect call.

> sock = new zmq::socket_t(ctxt, ZMQ_SUB);

> sock->connect("inproc://something"); //<-- FAILS HERE!

> Currently I have some confusion as to why it works this way in the
> host, because I have a subscriber connecting to an inproc instance
> that doesn't have anything bound at yet, but the missing message
> problem solver in the ZMQ guide says start subscribers first and
> then the publisher. In any case, it works very well on the host.
First of all are you sure the socket was bound BEFORE you connect to it? When 
you start your server and client in separate threads (which I presume you do) 
you need to make sure that socket is bound before your client thread starts. 

I had the similar issue myself and I ended up writing a separate server_start() 
function for the server using common mutex/condition to synchronize socket 
creation (create mutex/condition, start the server thread thread, wait on the 
condition and in the server thread I bind the socket, signal on the condition). 
This way it is guaranteed that when server_start() function exits the socket is 
bound and ready to roll. Of course, you can use any thread synchronization 
technique, mutex/condition is just an example. 

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


[zeromq-dev] Lazy pirate alternative implementation

2014-06-12 Thread Dmitri Toubelis
Hi,

I needed to implement a pattern similar to "lazy pirate" from the guide for my 
project. However, the idea of reconnecting the socket upon timeout looks kind 
of lame to me, so I implemented it differently:

http://pastebin.com/KFSBtK8C

It works okay but is there anything obviously wrong with this approach? Are 
there any potential gotchas?

P.S.: I'm using ZMQ 2.1.x
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev


Re: [zeromq-dev] "inproc" socket connection fails onCentos5/AmazonEC

2010-07-19 Thread Dmitri Toubelis
Sorry guys it's my own fault. There is an oversight in my code - I bind()
and connect() sockets sequentially but in separate threads, so it is not
exactly a sequential execution. Thanks to everybody who responded. Sorry for
the false alarm.

Dmitri

> -Original Message-
> From: zeromq-dev-boun...@lists.zeromq.org 
> [mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of 
> Martin Sustrik
> Sent: July 19, 2010 2:41 AM
> To: 0MQ development list
> Subject: Re: [zeromq-dev] "inproc" socket connection fails 
> onCentos5/AmazonEC
> 
> Dmitri Toubelis wrote:
> > Martin,
> > 
> > I tried it already and if I introduce a small delay after 
> binding a socket,
> > then everything works as supposed to. However, I bind and 
> then connect
> > sockets sequentially from a single thread, so if these 
> calls are synchronous
> > they should be executed in a right sequence. Is there any 
> "asynchronicity"
> > in socket binding? If so then is there a way to disable it?
> 
> There is no asynchronicity fro "inproc" transport. Can you 
> provide the 
> code to reproduce the problem?
> 
> > I also noticed that socket binding on Centos5 platform 
> sometimes fails too.
> > I will try adding another delay after socket creation and 
> before binding but
> > this error is more rare and harder to reproduce.
> > 
> > I also tried it on non-Amazon machine to rule out their 
> custom kernel, but
> > result is still the same.
> 
> The code for inproc transport is platform-agnostic.
> 
> Martin
> ___
> 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] "inproc" socket connection fails onCentos5/AmazonEC

2010-07-18 Thread Dmitri Toubelis
Martin,

I tried it already and if I introduce a small delay after binding a socket,
then everything works as supposed to. However, I bind and then connect
sockets sequentially from a single thread, so if these calls are synchronous
they should be executed in a right sequence. Is there any "asynchronicity"
in socket binding? If so then is there a way to disable it?

I also noticed that socket binding on Centos5 platform sometimes fails too.
I will try adding another delay after socket creation and before binding but
this error is more rare and harder to reproduce.

I also tried it on non-Amazon machine to rule out their custom kernel, but
result is still the same.

> -Original Message-
> From: zeromq-dev-boun...@lists.zeromq.org 
> [mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of 
> Martin Hurton
> Sent: July 19, 2010 2:29 AM
> To: 0MQ development list
> Subject: Re: [zeromq-dev] "inproc" socket connection fails 
> onCentos5/AmazonEC
> 
> Hi Dmitri,
> 
> I think this is a timing issue; you call connect() before the bind ()
> has finished.
> Try to postpone  the connect() call by 1 second.
> 
> - Martin
> 
> On Mon, Jul 19, 2010 at 5:12 AM, Dmitri Toubelis
>  wrote:
> > Some more information on this issue. This is happening with 
> PUB/SUB sockets.
> > The program successfully binds SUB socket to inproc 
> endpoint. But then
> > subsequent connect to corresponding PUB socket fails with 
> "Connection
> > refused" error.
> >
> > -Original Message-
> > From: zeromq-dev-boun...@lists.zeromq.org
> > [mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of 
> Dmitri Toubelis
> > Sent: July 18, 2010 10:12 PM
> > To: zeromq-dev@lists.zeromq.org
> > Subject: [zeromq-dev] "inproc" socket connection fails on 
> Centos5/AmazonEC
> >
> > I'm trying to run my code that makes use of "inproc" 
> sockets on Centos5
> > (running on Amazon) and it fails with "Connection refused" 
> message. It works
> > fine on my development machine which is FC7. Is this a 
> known issue? Is there
> > any workaround?
> >
> > Regards,
> > Dmitri
> >
> > ___
> > 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

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


Re: [zeromq-dev] PUB/SUB with multiple publishers

2010-07-18 Thread Dmitri Toubelis
Thanks. This is exactly what I did with Matt's help. Works like a charm.

> -Original Message-
> From: zeromq-dev-boun...@lists.zeromq.org 
> [mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of chris
> Sent: July 19, 2010 12:17 AM
> To: zeromq-dev@lists.zeromq.org
> Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers
> 
> Dmitri Toubelis  alkeron.com> writes:
> > I have a scenario when I need to use PUB/SUB scheme with 
> multiple publishers.
> 
> If I've understood you correctly...
> 
> You'll need a topology that looks like this:
> 
> pub   sub
>\ /
> pub-s1--fsub/fpub--s2-sub
>/ \
> pub   sub
> 
> Both the 'pub'lishers and the 'sub'scribers must "connect" to 
> their respective
> sockets, s1 and s2.
> 
> fsub and fpub must "bind" s1 and s2 sockets respectively and 
> can use a simple
> forwarder device as an implementation.
> 
> Basically, what you do, is create two sockets.  Bind s1 as 
> ZMQ_PUB and bind s2
> as ZMQ_SUB.  Create ZMQ_FORWARDER devices having s1 as the 
> insocket, and s2 as
> the outsocket.
> 
> Then, as you need, connect publishers to s1 and connect 
> subscribers to s2.
> 
> regards,
> 
> chris
> 
> 
> ___
> 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] "inproc" socket connection fails on Centos5/AmazonEC

2010-07-18 Thread Dmitri Toubelis
Some more information on this issue. This is happening with PUB/SUB sockets.
The program successfully binds SUB socket to inproc endpoint. But then
subsequent connect to corresponding PUB socket fails with "Connection
refused" error. 

-Original Message-
From: zeromq-dev-boun...@lists.zeromq.org
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Dmitri Toubelis
Sent: July 18, 2010 10:12 PM
To: zeromq-dev@lists.zeromq.org
Subject: [zeromq-dev] "inproc" socket connection fails on Centos5/AmazonEC

I'm trying to run my code that makes use of "inproc" sockets on Centos5
(running on Amazon) and it fails with "Connection refused" message. It works
fine on my development machine which is FC7. Is this a known issue? Is there
any workaround?

Regards,
Dmitri

___
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] "inproc" socket connection fails on Centos5/AmazonEC

2010-07-18 Thread Dmitri Toubelis
I'm trying to run my code that makes use of "inproc" sockets on Centos5
(running on Amazon) and it fails with "Connection refused" message. It works
fine on my development machine which is FC7. Is this a known issue? Is there
any workaround?

Regards,
Dmitri

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


[zeromq-dev] Graceful shutdown of device

2010-07-16 Thread Dmitri Toubelis
I looked at device() implementation and noticed that it actually implemented
as an infinite loop. I think it would be nice to be able shut the device
down gracefully. I would imagine embedding the device into a class and
shutting it down from finalizer/destructor. Any thoughts?

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


Re: [zeromq-dev] PUB/SUB with multiple publishers

2010-07-16 Thread Dmitri Toubelis
Thanks Matt. This works for me rather nicely on Linux with C API !!! It
would be cool to have this trick documented.

Regards,
Dmitri

-Original Message-
From: zeromq-dev-boun...@lists.zeromq.org
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Matt Weinstein
Sent: July 16, 2010 10:57 PM
To: 0MQ development list
Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers

Here's a tarball of a working version from my Mac.
Apologies for any coding oversights, it's late.



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


Re: [zeromq-dev] PUB/SUB with multiple publishers

2010-07-16 Thread Dmitri Toubelis
I've abandoned this idea for now, it seems easier to implement my own
broker, then try to make ZMQ to what it is not designed to do. It would be
nice to see this feature in a future releases though. It is not a classical
PUB/SUB pattern but I think it is way more powerful. Can I suggest it as a
feature request? It should be rather straightforward fix.

-Original Message-
From: zeromq-dev-boun...@lists.zeromq.org
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of david starkweather
Sent: July 16, 2010 8:42 PM
To: 0MQ development list
Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers

I recently tried something similar.  My aim was to have a main publisher
socket in the main thread, and then each worker thread have a another
publisher socket.  I would then have a pipe between the worker sockets
and a sub socket in the main thread.  It is my understanding that the
forwarder device is supposed to work for this scenario - i.e. forward
from the sub skt to the main pub skt.  I recieved no errors, but none of
the messages got delivered to the other sub skts that subscribed.

I managed to implement my own queue in which I forward all messages, and
then have one publisher thread to just publish messages.  I have only
been able to get the pub/sub mechanism to work when there is just one
publisher.  If anyone has any alternate ideas, I'd be interested.
thanks.

Grant Starkweather

On Fri, 2010-07-16 at 13:34 -0400, Dmitri Toubelis wrote:
> I have a scenario when I need to use PUB/SUB scheme with multiple
> publishers. Is it possible to do with "inproc" transport? 
>  
> Here is what I tried:
> - create PUB socket and bind it to "inproc://pipe" endpoint
> - create another PUB socket and connect it to the same "inproc://pipe"
> endpoint
> - create SUB socket for each subscriber and connect them to thre
> "inproc://pipe" endpoint.
> - publish message using second publisher.
>  
> I'm getting no error, but message is not getting delivered to
> subscribers. Am I doing something wrong?
>  
> Any help is appreciated.
> ___
> 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] PUB/SUB with multiple publishers

2010-07-16 Thread Dmitri Toubelis
Thanks Matt,

I will try your suggestion. There is not much documentation on devices, so
it looks like I need to dig into the code.

What I'm trying to achieve here is N-way communication scheme, something
analogous to direct exchange in AMQP. The way I was thinking was to create N
nodes that could publish to the same bus and have subscribers, that only
receive messages directed to them. Each node is both publisher and
subscriber, it receives message from the bus and depending on workflow sends
it to other subscribers using proper subscription key. So, I'm expecting to
have 4+ publishers on the bus and equal number of subscribers. It is
straightforward to do using AMQP but I'm still not sure what is the proper
ZMQ way for this.

Dmitri



From: zeromq-dev-boun...@lists.zeromq.org
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Matt Weinstein
Sent: July 16, 2010 2:56 PM
To: 0MQ development list
Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers


I think your PUB from the second publisher went to the first publisher at
the other end of the pipe ? 

You might try using a device() to connect two sets of sockets back-to-back,
just like the server example.

I believe you'd do something like

create "inproc://pubsource"
device:
bind as a SUB
subscribe to all ("")
publishers:
connect as a PUB

on the other side:
device:
bind as a PUB
subscribers
connect as a SUB
subscribe to all ("")

I think the "one way" device can be used as a model, you're only going one
way :-)

On Jul 16, 2010, at 2:06 PM, Dmitri Toubelis wrote:


I call bind only once. The second time I use connect and it returns
0.
 
Dmitri Toubelis
Solution Architect / Director @ Alkeron Multimedia
cell: +1-647-400-3876
email: dmitri.toube...@alkeron.com
<mailto:dmitri.toube...@alkeron.com> 
 



From: zeromq-dev-boun...@lists.zeromq.org
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Chuck Remes
Sent: July 16, 2010 1:48 PM
To: 0MQ development list
Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers


On Jul 16, 2010, at 12:34 PM, Dmitri Toubelis wrote:


I have a scenario when I need to use PUB/SUB
scheme with multiple publishers. Is it possible to do with "inproc"
transport? 
 
Here is what I tried:
- create PUB socket and bind it to "inproc://pipe" endpoint
- create another PUB socket and connect it to the same
"inproc://pipe" endpoint
- create SUB socket for each subscriber and connect them to
thre "inproc://pipe" endpoint.
- publish message using second publisher.
 
I'm getting no error, but message is not getting delivered
to subscribers. Am I doing something wrong?


I don't think it is possible to have multiple sockets bind to the
same endpoint. Are you certain that the result code from calling bind is 0?
If it is, then this is likely a bug and should be reported (with sample
code).

Alternately, if you are running this on Windows then I don't think
inproc or ipc transports are supported on that platform. That should also
error out (if you are on Windows).

cr


___
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] PUB/SUB with multiple publishers

2010-07-16 Thread Dmitri Toubelis
I call bind only once. The second time I use connect and it returns 0.
 
Dmitri Toubelis
Solution Architect / Director @ Alkeron Multimedia
cell: +1-647-400-3876
email:  <mailto:dmitri.toube...@alkeron.com> dmitri.toube...@alkeron.com
 

  _  

From: zeromq-dev-boun...@lists.zeromq.org
[mailto:zeromq-dev-boun...@lists.zeromq.org] On Behalf Of Chuck Remes
Sent: July 16, 2010 1:48 PM
To: 0MQ development list
Subject: Re: [zeromq-dev] PUB/SUB with multiple publishers


On Jul 16, 2010, at 12:34 PM, Dmitri Toubelis wrote:



I have a scenario when I need to use PUB/SUB scheme with multiple
publishers. Is it possible to do with "inproc" transport? 
 
Here is what I tried:
- create PUB socket and bind it to "inproc://pipe" endpoint
- create another PUB socket and connect it to the same "inproc://pipe"
endpoint
- create SUB socket for each subscriber and connect them to thre
"inproc://pipe" endpoint.
- publish message using second publisher.
 
I'm getting no error, but message is not getting delivered to subscribers.
Am I doing something wrong?


I don't think it is possible to have multiple sockets bind to the same
endpoint. Are you certain that the result code from calling bind is 0? If it
is, then this is likely a bug and should be reported (with sample code).

Alternately, if you are running this on Windows then I don't think inproc or
ipc transports are supported on that platform. That should also error out
(if you are on Windows).

cr


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


[zeromq-dev] PUB/SUB with multiple publishers

2010-07-16 Thread Dmitri Toubelis
I have a scenario when I need to use PUB/SUB scheme with multiple
publishers. Is it possible to do with "inproc" transport? 
 
Here is what I tried:
- create PUB socket and bind it to "inproc://pipe" endpoint
- create another PUB socket and connect it to the same "inproc://pipe"
endpoint
- create SUB socket for each subscriber and connect them to thre
"inproc://pipe" endpoint.
- publish message using second publisher.
 
I'm getting no error, but message is not getting delivered to subscribers.
Am I doing something wrong?
 
Any help is appreciated.
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev