Re: [zeromq-dev] It looks like socket id's can't change with a router-router topology. Is that correct?

2014-09-18 Thread Goswin von Brederlow
On Wed, Sep 17, 2014 at 03:55:09PM -0400, Mark Wright wrote:
 I have a router-router setup (destination IDs are acquired via a
 broadcast/response, similar to the Freelance pattern  in the ZMQ book).
 
 I've noticed that if my destinations go down and come back up with a new
 ID, clients can't route to that ID.  I'm using 4.0.3.

Are you sure they have a new ID? I'm guessing not.

You have to allow reused IDs to take over the ID. Otherwise the
messages keeps getting send to the old connection. See socket options.

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


Re: [zeromq-dev] It looks like socket id's can't change with a router-router topology. Is that correct?

2014-09-18 Thread Justin Karneges
On 09/18/2014 02:23 AM, Goswin von Brederlow wrote:
 On Wed, Sep 17, 2014 at 03:55:09PM -0400, Mark Wright wrote:
 I have a router-router setup (destination IDs are acquired via a
 broadcast/response, similar to the Freelance pattern  in the ZMQ book).

 I've noticed that if my destinations go down and come back up with a new
 ID, clients can't route to that ID.  I'm using 4.0.3.

 Are you sure they have a new ID? I'm guessing not.

 You have to allow reused IDs to take over the ID. Otherwise the
 messages keeps getting send to the old connection. See socket options.

Which socket option controls this?

By the way, there's a thread from back in Feb when I reported the same 
issue as Mark:
http://lists.zeromq.org/pipermail/zeromq-dev/2014-February/025202.html

Justin

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


Re: [zeromq-dev] It looks like socket id's can't change with a router-router topology. Is that correct?

2014-09-18 Thread Pieter Hintjens
It's the ZMQ_ROUTER_HANDOVER option.

On Thu, Sep 18, 2014 at 7:28 PM, Justin Karneges jus...@affinix.com wrote:
 On 09/18/2014 02:23 AM, Goswin von Brederlow wrote:
 On Wed, Sep 17, 2014 at 03:55:09PM -0400, Mark Wright wrote:
 I have a router-router setup (destination IDs are acquired via a
 broadcast/response, similar to the Freelance pattern  in the ZMQ book).

 I've noticed that if my destinations go down and come back up with a new
 ID, clients can't route to that ID.  I'm using 4.0.3.

 Are you sure they have a new ID? I'm guessing not.

 You have to allow reused IDs to take over the ID. Otherwise the
 messages keeps getting send to the old connection. See socket options.

 Which socket option controls this?

 By the way, there's a thread from back in Feb when I reported the same
 issue as Mark:
 http://lists.zeromq.org/pipermail/zeromq-dev/2014-February/025202.html

 Justin

 ___
 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] It looks like socket id's can't change with a router-router topology. Is that correct?

2014-09-17 Thread Mark Wright
I have a router-router setup (destination IDs are acquired via a
broadcast/response, similar to the Freelance pattern  in the ZMQ book).

I've noticed that if my destinations go down and come back up with a new
ID, clients can't route to that ID.  I'm using 4.0.3.

This code demonstrates the issue (on windows - although the Sleep() call is
the only platform-specific call).  It creates a client and server, sends
from client to server, stops the server and starts a new one with the same
ID, then stops the server and starts a new with (on the same port) with a
different id.  The first two sends succeed, the last one fails:

#include zmq.h
#include zmq_utils.h
#include iostream

int
route_send (void *socket, const char *id, const char *data)
{
  int rc = 0;

  rc = zmq_send (socket, id, strlen (id), ZMQ_SNDMORE); // server addr
  if (rc == -1)
return 0;
  rc = zmq_send (socket, , 0, ZMQ_SNDMORE); // null
  if (rc == -1)
return 0;
  rc = zmq_send (socket, data, strlen (data), 0); // data
  if (rc == -1)
return 0;

  return 1;
}

int
route_recv (void *socket)
{
  int rc = 0;

  char buf[100];

  rc = zmq_recv (socket, buf, 100, 0); // client addr
  if (rc == -1)
return 0;
  printf (client addr received.\n);
  rc = zmq_recv (socket, buf, 100, 0); // null
  if (rc == -1)
return 0;
  printf (null received.\n);
  rc = zmq_recv (socket, buf, 100, 0); // data
  if (rc == -1)
return 0;
  buf[rc] = 0;
  printf (data received: %s\n, buf);

  return 1;
}


int
main ()
{
  int rc = 0;

  static void *ctx = zmq_ctx_new ();

  // server 1 setup
  void *server = zmq_socket (ctx, ZMQ_ROUTER);
  rc = zmq_setsockopt (server, ZMQ_IDENTITY, idserver0001, 12);
  rc = zmq_bind (server, tcp://127.0.0.1:3);
  if (rc == -1) {
return 1;
  }

  // client setup
  void *client = zmq_socket (ctx, ZMQ_ROUTER);
  rc = zmq_setsockopt (server, ZMQ_IDENTITY, idclient0001, 12);
  if (rc == -1)
return 1;
  rc = zmq_connect (client, tcp://127.0.0.1:3);
  if (rc == -1)
return 1;

  Sleep (50);

  printf(sending to server 1\n);
  route_send (client, idserver0001, test data 1);
  printf(receiving in server 1\n);
  route_recv (server);
  rc = zmq_close (server);
  if (rc == -1)
return 1;

  // server 2 setup
  void *server2 = zmq_socket (ctx, ZMQ_ROUTER);
  rc = zmq_setsockopt (server2, ZMQ_IDENTITY, idserver0001, 12);
  rc = zmq_bind (server2, tcp://127.0.0.1:3);
  if (rc == -1)
return 1;
  Sleep (3000);

  printf(sending to server 2\n);
  route_send (client, idserver0001, test data 2);
  printf(receiving in server 2\n);
  route_recv (server2);
  rc = zmq_close (server2);
  if (rc == -1)
return 1;

  // server 3 setup
  void *server3 = zmq_socket (ctx, ZMQ_ROUTER);
  rc = zmq_setsockopt (server3, ZMQ_IDENTITY, idserver0003, 12);
  rc = zmq_bind (server3, tcp://127.0.0.1:3);
  if (rc == -1)
return 1;
  Sleep (3000);

  printf(sending to server 3 i (id has changed)\n);
  route_send (client, idserver0003, test data 2);
  printf(receiving in server 3\n);
  route_recv (server3);
  rc = zmq_close (client);
  if (rc == -1)
return 1;
  rc = zmq_close (server3);
  if (rc == -1)
return 1;

  rc = zmq_close (client);
  if (rc == -1)
return 1;
  rc = zmq_ctx_shutdown (ctx);
  if (rc == -1)
return 1;
  rc = zmq_ctx_destroy (ctx);
  if (rc == -1)
return 1;

  return 0;
}






-- 
Mark Wright
markscottwri...@gmail.com
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
http://lists.zeromq.org/mailman/listinfo/zeromq-dev