Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!