1

I have a DEALER socket rending to a ROUTER, and once the message arrives, i cant decode it as json, if i print the received text and copy it to a python terminal, i can decode it though, but the receiving code is unable.

here is the code sending:

self._out_socket = self._out_context.socket(zmq.DEALER)
self._out_socket.connect("ipc://testout")
self._out_socket.send_json(bump)

here is the code receiving it:

ip_soc.socket(zmq.ROUTER)
ip_soc.socket.bind("ipc://testout")
ip_stream = ZMQStream(ip_soc.socket)
ip_stream.on_recv(send_res)
#... ioloop start here to wait

when this message is sent:

{'index': 0, 'image_generated': 'false', 'resdict': [], 'result': [' (\\mathrm{\\%i}1) \x05\x05'], '_id': u'1ceb8c99c1a248a48418a6067b335613', 'purpose': 'result'}

here is what i receive:

['\x00k\x8bEg', '{"index":0,"image_generated":"false","resdict":[],"result":[" (\\\\mathrm{\\\\%i}1) \\u0005\\u0005"],"_id":"1ceb8c99c1a248a48418a6067b335613","purpose":"result"}']

if i try to decode it (second part of above list:)

dictionary = json.loads(message[1])

im met with this error:

No JSON object could be decoded 

what is going wrong? The same code works fine if i use PUSH and PULL. The final result i'd like it an N to 1 zmq scheme where multiple independent processes can send to one receiver thats why im trying to use DEALER-ROUTER.

mike
  • 897
  • 2
  • 10
  • 29

0 Answers0