JustinTulloss / zeromq.node

Node.js bindings to the zeromq library
MIT License
1.65k stars 284 forks source link

Connect, close then re-connect zmq req socket dose not send messages on reconnected socket #556

Open gprasadg opened 8 years ago

gprasadg commented 8 years ago

Hello ,

I have implemented timeout and re-connection on zmq req socket but on re-connection unable to send messages on new socket . following is my implementation.

  1. If there is no response from the 'rep' socket for 3 sec i have closed existing 'req' socket and created a new one then sent a test message .
  2. I have enabled motoring log on both 'req' and 'rep' sockets . The rep socket shows log accept, endpoint: of 'rep' socket when i re-create new rep socket .
  3. issue : But i dint receive the test msg, as well as any new messages sent on the the new req socket .

steps to reproduce : prerequisite :

  1. Ubuntu 14 >
  2. node js
  3. ZMQ : sudo apt-get install g++ sudo apt-get install libtool pkg-config build-essential autoconf automake sudo apt-get install libzmq3-dev

Steps to run sample

  1. unzip req_res_reconnect.zip
  2. npm install requester & responder
  3. npm start both requester & responder on seprate terminsals

the output of sample is attached. PFA output.PNG

req_res_reconnect.zip output

suyogdilipkale commented 8 years ago

I have similar issue, please suggest solution

samliddicott commented 8 years ago

Also a problem for me, using nodejs 6.7, nodejs-zmq 2.15 libzmq 3.1

samliddicott commented 8 years ago

In my case nodejs is crashing in libzmq.3.1.0: [73569.549746] traps: node[18225] general protection ip:7fee3ad5acf0 sp:7ffd773a94a8 error:0 in libzmq.so.3.1.0[7fee3ad28000+5c000] bringing down the entire node process.

samliddicott commented 8 years ago

My problem seems to be fixed by socket.unmonitor() before I close() and let the socket go out of scope

samliddicott commented 8 years ago

and be careful not to call unmonitor on a socket that is not monitored or closed

ehallander9591 commented 7 years ago

I have the same issue.

Just to be clear, My nodejs side of the socket creates the 'req' socket, and when the peer side comes up the first time, I get the on('connect') and all is fine.

When I drop the peer, the on('disconnect') fires fine as well.

However, upon starting the peer side again, I do not get any more on('connect') messages.