Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

226
Visualizações
Can't listen to event sent from feathers server to client

I'm building a server which uses feathers and socketio.

I'm trying to use feathers channels mechanism to notify relevant users (connections) on relevant events.
Users belong to groups, so upon connecting to the server, I add the connection to the appropriate channels.
Upon publishing, inside app.publish, I'm getting the right data and see that the connection is attached to the channel, but can't figure out how to listen to it on the client.

This is a simplified channels.js:

app.on('connection', async (connection) => {
    connection.userGroups.forEach((group) => {
        app.channel(`group.groupId`).join(connection);
    }
    app.channel('1').join(connection); // dummy channel
}

app.publish((data, context) => {
    console.log(app.channel('1')); // output shown below
   
    return app.channel('1');
});

I'm using Postman as the client, sending a patch request, and listening to event named rooms patched (rooms is my service name) as described in feathers docs. No event is arriving.
If I'm using the raw socketio instance and emitting from there, everything seems to work fine and I get the event in the client

app.io.sockets.in('some room').emit('rooms patched', data);

but as I understand it, it overrides the whole mechanism of channels.

By examining the output from app.publish

Channel {
  _events: [Object: null prototype] {
    empty: [Function: bound onceWrapper] { listener: [Function (anonymous)] }
  },
  _eventsCount: 1,
  _maxListeners: undefined,
  connections: [
    {
      provider: 'socketio',
      headers: [Object],
      userInfo: [Object],
      userGroups: [Array]
    }
  ],
  data: null,
  [Symbol(kCapture)]: false
}

we can see that the connection is there.

Can anyone help me figure this problem out?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Does a port need to be opened on the clients end to create the channel so the communication line is 2 ways. Perhaps javascript will have some code to open up the clients port.

about 4 years ago · Juan Pablo Isaza Relatório

0

Found my silly typo mistake...
I accidently wrote

app.channel(`group.groupId`).join(connection);

when it really should be

app.channel(group.groupId).join(connection);

That's a shame really.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda