Quantcast
Channel: Active questions tagged zeromq - Stack Overflow
Viewing all articles
Browse latest Browse all 193

Unable to run ZMQStream with Tornado Event loop using python 3.7

$
0
0

I've been trying to set up a server / client using zmq eventloop for REQ / REP messaging. Since python 3 doesn't support the eventloop provided by zmq, I'm trying to run it with tornado's eventloop.

I'm facing issues running zmqStream with tornado's event loop using python 3.

I created the server / client code using zmq's zmqStream and tornado's eventloop. The client is sending the correct messages, but the server doesn't seem to be responding to the message requests.

The server side code:

from tornado import ioloopimport zmqdef echo(stream, msg):   stream.send_pyobj(msg)ctx = zmq.Context()socket = ctx.socket(zmq.REP)socket.bind('tcp://127.0.0.1:5678')stream = ZMQStream(socket)stream.on_recv(echo)ioloop.IOLoop.current().start()

The client side code:

import zmqcontext = zmq.Context()socket = context.socket(zmq.REQ)socket.connect("tcp://127.0.0.1:5678")for request in range (1,10):   print("Sending request ", request,"...")   socket.send_string("Hello")   # Get the reply.   message = socket.recv_pyobj()   print("Received reply ", request, "[", message, "]")

I was expecting the server to return back the request messages being sent by the client. But it is just not responding to the requests being sent.


Viewing all articles
Browse latest Browse all 193

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>