node.js - How to send and receive on same socket in arbitrary order using ZeroMQ for NodeJs? -


i writing application in nodejs using zeromq communicate application.

the nodejs application sends requests other application, responds when request has been handled. have started seeing issues, causing whole nodejs application freeze, when 2 requests sent short intervals.

when response arrives nodejs application, have event handler handles reponse. seems issue happens when have 2 outgoing requests before first 1 completed (i.e. response received other application).

i think have done wrong, perhaps have configured zeromq socket incorrect? using dealer socket, in turn communicates router socket on other end.

how should 1 setup zeromq socket nodejs send/receive data in arbitrary order?

so nodejs application setup follows ( have tried reduce code ):

zmqcommunicator = function(address) {   const self = this;    // setup socket   self.socket = zeromq.socket('dealer');   self.socket.isconnected = false;   self.socket.iswaitingforconnect = false;   self.address = address;    self.connect = function() {     self.socket.monitor(monitor_polling_period_ms, 0);     self.socket.identity = `testidentity`;     self.socket.connect(self.address);     self.socket.iswaitingforconnect = true;     self.socket.connectrequestmoment = moment();   };    self.disconnect = function() {     self.socket.isconnected = false;     self.socket.disconnect(self.brokeraddress);     self.socket.unmonitor();   };    //handle successful connect   self.socket.on('connect', meteor.bindenvironment(function (fd, ep) {       self.socket.iswaitingforconnect = false;       self.socket.isconnected = true;   }));     self.sendjobrequest = function(requestid, request) {     self.socket.send([new buffer(zmq_job_request), request]);   };    self.socket.on('message', meteor.bindenvironment(function (envelope, data) {         // handle response ........   })); }; 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -