No listeners found for event: "event name"
Msiavashi opened this issue · 5 comments
Hi,
Thanks for this great contribution and this amazing framework.
Recently I noticed one problem with defining requester and responder in a single file.
Consider file A includes:
const cote = require('cote');
const responder = new cote.Responder({name: "testresponder"});
const requester = new cote.Requester({name: "testrequester"});
requester.send({type: 'call'}, (res) => {
console.log(res);
});
and file B includes:
const cote = require('cote');
const responder = new cote.Responder({name: "callresponder"});
responder.on('call', (req, cb) => {
cb("test");
});
I first start the file B which is the responder and then I run the file A. the console log is:
testresponder > No listeners found for event: call
But when I delete the responder initiation in file A, it will work just fine. However, defining keys will solve the problem, but I don't know why this won't work without keys.
I was hoping that the error message would be clear: testresponder
on file A really doesn't have an event listener. if you do
responder.on('call', (req, cb) => {
cb("test");
});
on file A as well, it will work, and load balance between the one in file A and the one in file B.
Hmmm ... I don't get it why should I have the responder in my A file? Consider each file as an independent microservice, I want A to ask something from B, no more. In this case shouldn't the framework discover B?
If I'm gonna have two responders, which one gonna answer my A requester?
I'm sorry I'm a bit confused.
That's totally fine, then you shouldn't have a responder in file A. :) you got that error because you had a responder in A that can't handle the message call
.
I get it now! it seems I shouldn't initiate a responder when I have no listener on it.
Thanks for your help.
I get this error too:
this is my responder:
const cote = require('cote');
var auth_consumer = new cote.Responder({ name: 'auth_service' });
auth_consumer.on('generate-token', async (req, cb) => {
cb(null, {message: "ok", token: createTokens(req.device, req.exp), status:200})
});
I am getting this in One in between two requests :
socket-service > No listeners found for event: generate-token