Hi Stephen.

I unknown if the previous message was sent to group list due to arrive
moderation notification about of the long of same. By this reason I sent
this message now.


In first instance, thanks for your answering

I am set  the identity of each peer/client in their respective ZMQ_DEALER
client-side  with

*client.setsockopt(ZMQ_IDENTITY, "PEER1", 5);*

Is this right? The identity frame is set on the DEALER client/peer side.

When this ZMQ_DEALER client sends a message to ZMQ_ROUTER on the server
router in command line interface I can see:

[b'PEER1', b'', b'Testing sending some data']

This means, that the ROUTER socket, when receiving the message prepend the
identity message part of the originating peer to the message before passing
it to the application. It's right.

And you have the reason, the message sent by the DEALER to ROUTER is
returned to him.

The same behavior happens on the peer2 or another DEALER client

If I am attaching the identity of each DEALER before to connect to ROUTER
... how to can I figure the identity frame of other DEALER destination of
this message?
This should be making on the ROUTER side?

In the first instance, to starting in my implementation, I need that some
message sent by any DEALER, this will be visualized by any another DEALER
without matter how many DEALERS (one or many) are connected to the
ZMQ_ROUTER.

In this sense ... Is necessary meet about of the identity frame of other
DEALER or other DEALERS?

If I have DEALER A, DEALER B, and DEALER C, and ROUTER

then:

DEALER A send a message ...
And  I want that message from DEALER A to arrive at DEALER B and DEALER C
and so other DEALERS that can be joined to my session conversation ...

In this ideas order, is necessary met the identity frame of DEALER B and
DEALER C previously so that this message to arrive him?

How to know the identity frames of each DEALER existent on my
implementation?
This is made on the ROUTER side?
I haven't clear this.

Best Regards




Bernardo Augusto García Loaiza
Ingeniero de Sistemas
Estudiante de Maestría en Ingeniería Informática - Universidad EAFIT
http://about.me/bgarcial


On Thu, Mar 15, 2018 at 6:59 AM, Stephen Gray <riskybizl...@live.com> wrote:

> Hi Bernardo,
>
>
>
>                 The http://zguide.zeromq.org/page:all tells us;
>
>
>
> “The ROUTER socket, unlike other sockets, tracks every connection it has,
> and tells the caller about these. The way it tells the caller is to stick
> the connection *identity* in front of each message received. An identity,
> sometimes called an *address*, is just a binary string with no meaning
> except "this is a unique handle to the connection". Then, when you send a
> message via a ROUTER socket, you first send an identity frame.
>
> The zmq_socket() <http://api.zeromq.org/3-2:zmq_socket> man page
> describes it thus:
>
> When receiving messages a ZMQ_ROUTER socket shall prepend a message part
> containing the identity of the originating peer to the message before
> passing it to the application. Messages received are fair-queued from among
> all connected peers. When sending messages a ZMQ_ROUTER socket shall remove
> the first part of the message and use it to determine the identity of the
> peer the message shall be routed to.”
>
> Though I haven’t run your code I suspect that your ROUTER will bounce back
> your test message to the originating DEALER?  This would be because the
> identity frame was prepended by the ROUTER on receipt and the message is
> sent back through the ROUTER; where it strips off the identity and uses the
> value to route the message back to the relevant DEALER.
>
> In order to send it to a different destination it is necessary to have the
> ‘identity’ frame of that other DEALER and to prepend that identity when you
> send the message; otherwise the ROUTER won’t know where to deliver the
> message.
>
> When receiving off a ROUTER socket the ‘identity’ is the first frame of
> the message.  You could capture it and store it. Then later prepend it as
> the first frame of a message you wish to send to a particular DEALER via
> your ROUTER.
>
> HTH,
>
> Stephen
>
>
>
>
>
> *From:* zeromq-dev [mailto:zeromq-dev-boun...@lists.zeromq.org] *On
> Behalf Of *Bernardo Augusto García Loaiza
> *Sent:* 14 March 2018 23:17
> *To:* ZeroMQ development list
> *Subject:* [zeromq-dev] ZMQ DEALER - ROUTER Communication
>
>
>
> I am currently working on a project that requires some communication over
> the network of a different data types from some entities of a distributed
> system and I am using ZMQ.
>
> The main goal of the project is to have a central node which services
> clients which can connect at any time. For each client connected, the
> central node should manage the message communication between the two.
>
> Currently, and by the moment, all communication is happening over TCP.
>
> The clients need to send and receive messages at any time so they are
> *ZMQ_DEALER* type sockets and the central node is *ZMQ_ROUTER*
>
> I have been reading, about of the different patterns communication and I
> think the Asynchronous Client/Server pattern
> <http://zguide.zeromq.org/page:all#The-Asynchronous-Client-Server-Pattern>
> is suited because I am interested in having several clients talking to each
> other in a collaborative way, having maybe a server broker or middleware,
> which be useful to receive and forward messages between entities related
> and because basically, the DEALER - TO - ROUTER
> <http://zguide.zeromq.org/php:chapter3#The-DEALER-to-ROUTER-Combination>
> combination is that I need.
>
>
>
> I have a ZMQ_DEALER socket client which connect to ZMQ_ROUTER socket
> server
>
> #include <zmq.hpp>
>
> #include "zhelpers.hpp"
>
> using namespace std;
>
>
>
> int main(int argc, char *argv[])
>
> {
>
>
>
>     zmq::context_t context(1);
>
>     zmq::socket_t client(context, ZMQ_DEALER);
>
>
>
>     const string endpoint = "tcp://localhost:5559";
>
>
>
>     client.setsockopt(ZMQ_IDENTITY, "PEER1", 5);
>
>     cout << "Connecting to ZMQ Network Manager " << endpoint << "..." << endl;
>
>     client.connect(endpoint);
>
>     for (int request = 0; request < 10; request++)
>
>     {
>
>
>
>         s_sendmore(client, "");
>
>         s_send(client, "Testing sending some data");
>
>
>
>         std::string string = s_recv(client);
>
>
>
>         std::cout << "Received reply " << request
>
>                   << " [" << string << "]" << std::endl;
>
>     }
>
> }
>
>
> On my server code, I have a ZMQ_ROUTER which receive and manage the
> messages is, making bind it to a well port. This server is made in Python
>
> import zmq
>
> context = zmq.Context()
>
> frontend = context.socket(zmq.ROUTER)
>
> frontend.bind("tcp://*:5559")
>
>
>
> # Initialize a poll set
>
> poller = zmq.Poller()
>
> poller.register(frontend, zmq.POLLIN)
>
>
>
> print("Creating Server Network Manager Router")
>
>
>
> while True:
>
>     socks = dict(poller.poll())
>
>
>
>     if socks.get(frontend) == zmq.POLLIN:
>
>         message = frontend.recv_multipart()
>
>         print(message)
>
>         frontend.send_multipart(message)
>
>
> On my other peer/client I have the following:
>
> #include <zmq.hpp>
>
> #include "zhelpers.hpp"
>
> using namespace std;
>
>
>
> int main (int argc, char *argv[])
>
> {
>
>
>
>     zmq::context_t context(1);
>
>     zmq::socket_t peer2(context, ZMQ_DEALER);
>
>
>
>     const string endpoint = "tcp://localhost:5559";
>
>
>
>     peer2.setsockopt(ZMQ_IDENTITY, "PEER2", 5);
>
>     cout << "Connecting to ZMQ Network Manager " << endpoint << "..." << endl;
>
>     peer2.connect(endpoint);
>
>     //s_sendmore(peer2, "");
>
>     //s_send(peer2, "Probando");
>
>
>
>     //std::string string = s_recv(peer2);
>
>
>
>     //std::cout << "Received reply " << " [" << string << "]" << std::endl;
>
>
>
>     for (int request = 0; request < 10; request++)
>
>     {
>
>
>
>         s_sendmore(peer2, "");
>
>         s_send(peer2, "Probando");
>
>
>
>         std::string string = s_recv(peer2);
>
>
>
>         std::cout << "Received reply " << request
>
>                   << " [" << string << "]" << std::endl;
>
>     }
>
>
>
> }
>
>
>
> But each that I execute some client, their respective messages do not
> arrive at another peer client. The messages arrive at ZMQ_ROUTER, but I
> haven't clear on my server code how to should I forward this messages to
> the respective clients.
>
> I think so (may be obvious) that in my server code, I am not sending
> messages.
>
>
>
>
> Bernardo Augusto García Loaiza
> Ingeniero de Sistemas
> Estudiante de Maestría en Ingeniería Informática - Universidad EAFIT
>
> http://about.me/bgarcial
>
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to