[zeromq-dev] Socket.connect doesn't raise any error

4 views
Skip to first unread message

Pazzo Da Legare

unread,
Mar 6, 2012, 4:37:36 AM3/6/12
to zerom...@lists.zeromq.org
Dear all,

I'm playing with zmq binding for python, with PUSH/PULL socket.
How can I get an error if connect fails?

I try to connect to "nothing": I tried both and unreachable/reachable
address but with no zmq PULL receiving on it.

----snip----
import zmq

context = zmq.Context()
socket = context.socket(zmq.PUSH)

try:
socket.connect("tcp://159.214.12.12:23666")
except:
import sys
print "ERROR"
sys.exit(-1)

while True:
socket.send("aaaaaa")
print "try to send..."
----snip----

How can I:

- know if socket is connected?
- limit the length of buffered messages?
_______________________________________________
zeromq-dev mailing list
zerom...@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Ian Barber

unread,
Mar 6, 2012, 4:44:01 AM3/6/12
to ZeroMQ development list
On Tue, Mar 6, 2012 at 9:37 AM, Pazzo Da Legare <pazzod...@gmail.com> wrote:
Dear all,

I'm playing with zmq binding for python, with PUSH/PULL socket.
How can I get an error if connect fails?

ZeroMQ will just retry the connection for you, so you don't get a message if the connection is still pending.

- limit the length of buffered messages?

Look for the HWM socket options - they let you set a limit. Note that the limit is not really precise - things can be pushed into the TCP buffer, so your effective limit is likely to be TCP buffer size + HWM number of messages.

Ian
 

Pazzo Da Legare

unread,
Mar 6, 2012, 4:48:51 AM3/6/12
to ZeroMQ development list
Dear Ian,

Thank you for answer.

2012/3/6 Ian Barber <ian.b...@gmail.com>:


>> I'm playing with zmq binding for python, with PUSH/PULL socket.
>> How can I get an error if connect fails?
>
>
> ZeroMQ will just retry the connection for you, so you don't get a message if
> the connection is still pending.

Can I setup how long ZeroMQ have to retry?

>> - limit the length of buffered messages?
>
>
> Look for the HWM socket options - they let you set a limit. Note that the
> limit is not really precise - things can be pushed into the TCP buffer, so
> your effective limit is likely to be TCP buffer size + HWM number of
> messages.

I will give a look at HWM parameters, thanks again,

pz


> Ian

Chuck Remes

unread,
Mar 6, 2012, 9:20:46 AM3/6/12
to ZeroMQ development list

On Mar 6, 2012, at 3:48 AM, Pazzo Da Legare wrote:

> Dear Ian,
>
> Thank you for answer.
>
> 2012/3/6 Ian Barber <ian.b...@gmail.com>:
>>> I'm playing with zmq binding for python, with PUSH/PULL socket.
>>> How can I get an error if connect fails?
>>
>>
>> ZeroMQ will just retry the connection for you, so you don't get a message if
>> the connection is still pending.
>
> Can I setup how long ZeroMQ have to retry?

No. Please read the documentation, man pages and the FAQ. By at least reading the man pages, you'll see there is no support for this kind of timeout mechanism.

These docs can be found here:

guide: http://zguide.zeromq.org/page:all

man pages: http://api.zeromq.org/

faq: http://www.zeromq.org/area:faq

Pazzo Da Legare

unread,
Mar 6, 2012, 11:26:58 AM3/6/12
to ZeroMQ development list
Dear Chuck,

Thank you for your answer. I solved the problem at application level.

pazzodalegare


2012/3/6 Chuck Remes <cremes....@mac.com>:

Reply all
Reply to author
Forward
0 new messages