Call to Service Create not Broadcasting #2517
-
Hello everyone, I'm new to feathers and I'm a little puzzled as to why my service calls aren't broadcasting. I could also be misunderstanding how it works. As of right now I've got my server const app = express(feathers());
...
app.configure(socketio());
app.use("/readings", new ReadingService());
... And I've got the reading service that has a On the client side, I've got a line of code that I would like to be listening for create events. Currently that is: const socket = io(url);
const app = feathers();
// Set up Socket.io client with the socket
app.configure(socketio(socket));
...
socket.service("readings").on("create", (payload) => {
console.log({ message: "Readings Created", payload });
}); I've run a separate script that makes a client connection, and calls the create function in the service. I've verified that the function is called, but the above code in a separate client isn't being called. My understanding is that on the create an event should be broadcast, but there doesn't seem to be one. Any ideas on what I'm doing wrong? Any help is appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Events will only be broadcast to connections that have been registered with a channel with the simplest example shown in the API server quick start. In a generated application the standard behaviour is that events are only published to users that are authenticated. More details and links can be found in the Additionally your client side code example probably won't work. It should be const socket = io(url);
const app = feathers();
// Set up Socket.io client with the socket
app.configure(socketio(socket));
...
app.service("readings").on("created", (payload) => {
console.log({ message: "Readings Created", payload });
}); I highly recomend following the Feathers guide which discusses all those things. |
Beta Was this translation helpful? Give feedback.
Events will only be broadcast to connections that have been registered with a channel with the simplest example shown in the API server quick start. In a generated application the standard behaviour is that events are only published to users that are authenticated. More details and links can be found in the
channels.js
file.Additionally your client side code example probably won't work. It should be
app.service()
notsocket.service()
and.on('created')
not.on('create')
: