I'm making a publish subscribe using ZeroMQ. Here is a simplified code :
import zmq from 'zeromq';
import d from 'debug';
const debug = d('publisher');
let port = '8000';
let subject = 'FLIGHTS';
const socket = zmq.socket('pub');
socket.on('close', function(...toto) {
debug('connection closed');
});
socket.on('close_error', function(...toto) {
debug('error while closing connexion');
});
socket.monitor(10, 0);
socket.bindSync('tcp://*:' + port);
export function send(message: object) {
const jsonMessage = JSON.stringify(message);
socket.send([subject, jsonMessage]);
}
export function close() {
socket.close();
}
setTimeout( () =>
close()
, 3000 );
The problem I have is that the process won't exit even if the socket is closed after 3 seconds. I can't use process.exit because the module I'm making is used in a lot a jest tests. I didn't find anything in the ZeroMQ documentation. Can you help me, please ?
Thanks in advance.
via Alexandre DERNIAME
No comments:
Post a Comment