Re: [zeromq-dev] Lost message with PUSH/PULL

2016-07-01 Thread Doron Somech
So it is a confirmed bug, solving it might be complicated. I will take a
look tomorrow.

On Fri, Jul 1, 2016 at 5:53 PM, KIU Shueng Chuan  wrote:

> I have attached some minimal code here where doing a TCP connect to
> the PUSH bind socket makes the latter writable.
>
> Tested on 4.1.4
>
> On 30 June 2016 at 23:11, Doron Somech  wrote:
> > I think it might be the ZeroMQ behavior (which is probably a bug), once
> the
> > connection is open ZeroMQ start to queue messages for the connection,
> even
> > if handshake is not yet completed, so when you do telnet the message is
> not
> > discarded but queue for the telnet connection.
> >
> > I think only PUSH is affected by this behavior, also fixing it might be
> > hard, it also might be security issue, right now PUSH socket type is not
> > safe for internet use because of this.
> >
> > If you can I suggest you reverse the bind/connection so PUSH will connect
> > and PULL will bind. If not an option try to use ROUTER instead and have
> some
> > kind of handshake.
> >
> > Nice catch, I still want to make sure that is really what happen and see
> if
> > it possible to fix this easily..
> >
> > On Thu, Jun 30, 2016 at 11:32 AM, 王运来  wrote:
> >>
> >> Hi every guys:
> >>I got a problem which ZMQ will lost some messages with PUSH/PULL
> >> ZMQ socket.
> >>The scene like this:
> >>A: PUSH socket, bind address "tcp://*.1209"
> >>B: PULL socket, connect to "tcp://localhost:1209"
> >>
> >>Run the command "telnet localhost 1209" while A sending message
> to
> >> B.
> >>
> >>The result is B will miss  messages even if I set the option of
> >> ZMQ_IMMEDIATE to 1 like this:
> >>int immediate = 1;
> >>zmq_setsockopt(pSock, ZMQ_IMMEDIATE, , sizeof(immediate));
> >>
> >>   Is it right in this scene or is it should be?
> >>
> >>
> >>
> >>
> >>
> >> ___
> >> 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] Lost message with PUSH/PULL

2016-07-01 Thread KIU Shueng Chuan
I have attached some minimal code here where doing a TCP connect to
the PUSH bind socket makes the latter writable.

Tested on 4.1.4

On 30 June 2016 at 23:11, Doron Somech  wrote:
> I think it might be the ZeroMQ behavior (which is probably a bug), once the
> connection is open ZeroMQ start to queue messages for the connection, even
> if handshake is not yet completed, so when you do telnet the message is not
> discarded but queue for the telnet connection.
>
> I think only PUSH is affected by this behavior, also fixing it might be
> hard, it also might be security issue, right now PUSH socket type is not
> safe for internet use because of this.
>
> If you can I suggest you reverse the bind/connection so PUSH will connect
> and PULL will bind. If not an option try to use ROUTER instead and have some
> kind of handshake.
>
> Nice catch, I still want to make sure that is really what happen and see if
> it possible to fix this easily..
>
> On Thu, Jun 30, 2016 at 11:32 AM, 王运来  wrote:
>>
>> Hi every guys:
>>I got a problem which ZMQ will lost some messages with PUSH/PULL
>> ZMQ socket.
>>The scene like this:
>>A: PUSH socket, bind address "tcp://*.1209"
>>B: PULL socket, connect to "tcp://localhost:1209"
>>
>>Run the command "telnet localhost 1209" while A sending message to
>> B.
>>
>>The result is B will miss  messages even if I set the option of
>> ZMQ_IMMEDIATE to 1 like this:
>>int immediate = 1;
>>zmq_setsockopt(pSock, ZMQ_IMMEDIATE, , sizeof(immediate));
>>
>>   Is it right in this scene or is it should be?
>>
>>
>>
>>
>>
>> ___
>> 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
#include 
#include 

#include 
#include 
#include 
#include 

#include 

int main()
{
void *zctx = zmq_ctx_new();
void *zsock = zmq_socket(zctx, ZMQ_PUSH);
int rc = zmq_bind(zsock, "tcp://127.0.0.1:34567");
assert(rc!=-1);

rc = zmq_send(zsock, "ABC", 3, ZMQ_DONTWAIT);
assert(rc==-1); // expected not writable

int sockfd = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in saddr = {AF_INET, htons(34567), htonl(INADDR_LOOPBACK)};
rc = connect(sockfd, (struct sockaddr*), sizeof(saddr));
assert(rc==0);

zmq_pollitem_t item = {zsock, 0, ZMQ_POLLOUT};
rc = zmq_poll(, 1, 100);
assert(rc==1);  // oops, became writable
   
rc = zmq_send(zsock, "ABC", 3, ZMQ_DONTWAIT);
assert(rc==3);  // write succeeds despite no PULL socket connecting

close(sockfd);

int linger = 0;
rc = zmq_setsockopt(zsock, ZMQ_LINGER, , sizeof(linger));
assert(rc==0);

rc = zmq_close(zsock);
assert(rc==0);

// sometimes this blocks...
printf("destroying\n");
zmq_ctx_destroy(zctx);
}

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

Re: [zeromq-dev] Lost message with PUSH/PULL

2016-06-30 Thread Doron Somech
I think it might be the ZeroMQ behavior (which is probably a bug), once the
connection is open ZeroMQ start to queue messages for the connection, even
if handshake is not yet completed, so when you do telnet the message is not
discarded but queue for the telnet connection.

I think only PUSH is affected by this behavior, also fixing it might be
hard, it also might be security issue, right now PUSH socket type is not
safe for internet use because of this.

If you can I suggest you reverse the bind/connection so PUSH will connect
and PULL will bind. If not an option try to use ROUTER instead and have
some kind of handshake.

Nice catch, I still want to make sure that is really what happen and see if
it possible to fix this easily..

On Thu, Jun 30, 2016 at 11:32 AM, 王运来  wrote:

> Hi every guys:
>I got a problem which ZMQ will lost some messages with PUSH/PULL
> ZMQ socket.
>The scene like this:
>A: PUSH socket, bind address "tcp://*.1209"
>B: PULL socket, connect to "tcp://localhost:1209"
>
>Run the command "telnet localhost 1209" while A sending message to
> B.
>
>The result is B will miss  messages even if I set the option
> of ZMQ_IMMEDIATE to 1 like this:
>int immediate = 1;
>zmq_setsockopt(pSock, ZMQ_IMMEDIATE, , sizeof(immediate));
>
>   Is it right in this scene or is it should be?
>
>
>
>
> ___
> 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] Lost message with PUSH/PULL

2016-06-30 Thread Dermot Doran
The latest API documentation does suggest that messages are NOT discarded.
It would probably help everybody if you could provide the code (or at least
recreate your problem with a simpler example).  Creating a simple example
might even lead you to discover what is going wrong.  So it is definitely
well worth the effort!

On 30 June 2016 at 10:32, 王运来  wrote:

> Hi every guys:
>I got a problem which ZMQ will lost some messages with PUSH/PULL
> ZMQ socket.
>The scene like this:
>A: PUSH socket, bind address "tcp://*.1209"
>B: PULL socket, connect to "tcp://localhost:1209"
>
>Run the command "telnet localhost 1209" while A sending message to
> B.
>
>The result is B will miss  messages even if I set the option
> of ZMQ_IMMEDIATE to 1 like this:
>int immediate = 1;
>zmq_setsockopt(pSock, ZMQ_IMMEDIATE, , sizeof(immediate));
>
>   Is it right in this scene or is it should be?
>
>
>
>
> ___
> 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] Lost message with PUSH/PULL

2016-06-30 Thread 王运来
Hi every guys:
   I got a problem which ZMQ will lost some messages with PUSH/PULL ZMQ 
socket.
   The scene like this:
   A: PUSH socket, bind address "tcp://*.1209"
   B: PULL socket, connect to "tcp://localhost:1209"
   
   Run the command "telnet localhost 1209" while A sending message to B.


   The result is B will miss  messages even if I set the option of 
ZMQ_IMMEDIATE to 1 like this:
   int immediate = 1;
   zmq_setsockopt(pSock, ZMQ_IMMEDIATE, , sizeof(immediate));


  Is it right in this scene or is it should be?___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev