Hi Emile

Using the ROUTER socket type is a bit of an advanced pattern, and since
your worker didn't send a message first, the client doesn't know what I
would call the "return address".
The ROUTER isn't compatible with a peer socket of a REP according do this:
http://api.zeromq.org/4-2:zmq-socket

I would recommend changing both of your socket types to DEALER and try
that.  I think it will be closer to what you are looking for.


Mark

On Mon, Feb 4, 2019 at 3:25 AM Emile Achadde <[email protected]> wrote:

> Hello,
>
> I am new in 0MQ.
>
> I tried to run the example from there
> https://github.com/imatix/zguide2/blob/master/examples/Python/rtpapa.py
>
> I did some corrections to adapt the code to the new 0Mq version.
>
> I am running Debian 9.7 and Python 3.7.0
>
> when run this code waits for something.
>
> Could someone tell me what is wrong is the code below ?
>
> Best regards,
>
> Emile
>
> the code is here:
>
> # encoding: utf-8
> #
> #   Custom routing Router to Papa (ROUTER to REP)
> #
> #   Author: Jeremy Avnet (brainsik) <spork(dash)zmq(at)theory(dot)org>
> #
> # https://github.com/imatix/zguide2/blob/master/examples/Python/rtpapa.py
> # added 'b' in setsockopt and send commands
>
> import time
> import zmq
> import zhelpers
>
> context = zmq.Context()
> client = context.socket(zmq.ROUTER)
> client.bind("ipc://routing.ipc")
>
> worker = context.socket(zmq.REP)
> worker.setsockopt(zmq.IDENTITY, b"A")
> worker.connect("ipc://routing.ipc")
>
> # Wait for sockets to stabilize
> time.sleep(1)
>
> client.send(b"A", zmq.SNDMORE)
> client.send(b"address 3", zmq.SNDMORE)
> client.send(b"address 2", zmq.SNDMORE)
> client.send(b"address 1", zmq.SNDMORE)
> client.send(b"", zmq.SNDMORE)
> client.send(b"This is the workload")
>
> # Worker should get just the workload
> zhelpers.dump(worker)
>
> # We don't play with envelopes in the worker
> worker.send(b"This is the reply")
>
> # Now dump what we got off the ROUTER socket...
> zhelpers.dump(client)
>
> _______________________________________________
> zeromq-dev mailing list
> [email protected]
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
[email protected]
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to