getChannel('').topic('') always returning null


I’m trying to get a dynamic topic to broadcast an event but no matter what I try it’s always retuning null.

Channel register'tactical:*', 'TacticalUnitWsController')

Client code

init() { = Ws('ws://localhost:3333');;'open', () => { ='tactical:main');'message', this.onMessage.bind(this));

Trying to get the topic

const topic = Ws.getChannel('tactical:*').topic('tactical:main');
console.log({ topic });

It seems like everything I’m doing is right, the communication between the socket controller and the client is fine. But now I have to get the topic from a Http Controller to broadcast a message and I just can’t.

Is anything wrong with my code?

1 Like

Okay, so after some digging in this exact forum I found that it worked for someone after they commented this code on the server.js file.

const cluster = require('cluster')

if (cluster.isMaster) {
  for (let i = 0; i < 4; i++) {

I commented it and it’s now working. It’s strange because the docs say that this snippet of code is necessary. I hope I didn’t break anything.


It’s necessary when running in cluster mode :slightly_smiling_face:

1 Like

I feel dumb for not reading it properly… Thanks for the heads up!