-
Notifications
You must be signed in to change notification settings - Fork 487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replacing customHook/customRequest in ^6.0.0 #370
Comments
You have to write something like this:
|
Hi! Is there an update on this? Since many pervious issues recommended to use customHook/customRequest to solve common problems like #283 (comment), the removal of these functions is blocking me upgrading to socket.io v3. Should I consider #370 (comment) as the official workaround for now? I'm also curious about when would the future release with a replacement api happen? |
We have added some utility methods in Socket.IO v4 (the major bump is due to a minor breaking change and should not impact most users). Documentation: https://socket.io/docs/v3/migrating-from-3-x-to-4-0/#Additional-utility-methods Starting with Does it cover all your use cases? An user suggested to create another flag, |
@darrachequesne Thank you for the response! The customHook and customRequest methods were more flexible and allowed me perform some extra logic like gathering server status on every node along with node id. The suggested In general, I want know when handling communications happen only between servers (rpc calls), should I rely on socket.io-redis, or should I add a different redis based rpc layer? |
@rainy-me there is currently no official way to handle communication between servers, but we could indeed add one. I'm open to suggestions on this 🙏 |
@darrachequesne I mean it was partially doable just via customHook and customRequest, but since they are removed I have to find an alternative. It'll be really helpful to have it in |
I also do some custom things using |
Same here. I'm blocked from upgrading socket.io past v2 because of this removal. customRequest and customHook allowed us to have inter-node communication (i.e. node 1 telling node 2 to do something). The new methods fetchSockets, socketsJoin, socketsLeave and disconnectSockets) unfortunately do not cover all my use-cases. |
Syntax: ```js // server A io.serverSideEmit("hello", "world"); // server B io.on("hello", (arg) => { console.log(arg); // prints "world" }); ``` With acknowledgements: ```js // server A io.serverSideEmit("hello", "world", (err, responses) => { console.log(responses); // prints ["hi"] }); // server B io.on("hello", (arg, callback) => { callback("hi"); }); ``` This feature replaces the customHook/customRequest API from the Redis adapter: socketio/socket.io-redis-adapter#370
This new API replaces the customRequest/customHook methods that were removed in v6. Syntax: ```js // server A io.serverSideEmit("hello", "world"); // server B io.on("hello", (arg) => { console.log(arg); // prints "world" }); ``` With acknowledgements: ```js // server A io.serverSideEmit("hello", "world", (err, responses) => { console.log(responses); // prints ["hi"] }); // server B io.on("hello", (arg, callback) => { callback("hi"); }); ``` Related: #370
Seems |
Didn't update the thread. But yes, I was able to upgrade socket.io and use serverSideEmit as a replacement for customeRequest. Works like a charm and has been out in production since last week. Thanks a lot! |
@hmoush95 thanks for the update! 👍 Syntax of the io.serverSideEmit("hello", "world");
// on the other nodes
io.on("hello", (arg1) => {
console.log(arg1); // prints "world"
}); Let's close this now. |
Syntax: ```js // server A io.serverSideEmit("hello", "world"); // server B io.on("hello", (arg) => { console.log(arg); // prints "world" }); ``` With acknowledgements: ```js // server A io.serverSideEmit("hello", "world", (err, responses) => { console.log(responses); // prints ["hi"] }); // server B io.on("hello", (arg, callback) => { callback("hi"); }); ``` This feature replaces the customHook/customRequest API from the Redis adapter: socketio/socket.io-redis-adapter#370
According to the release notes for v6.0.0 in https://socket.io/blog/socket-io-redis-adapter-6-release/:
customHook and customRequest methods were removed Those methods will be replaced by a more intuitive API in a future iteration.
It would be nice to provide an alternative for the devs who were already using customHook and customRequest.
Also, it says that this will be available in a future version. When would that be? Why not simply leave the previous implementation on, as it was already working well?
Great work guys, just wondering about this since I have customHooks implemented in an existing project and would like to upgrade socket io.
The text was updated successfully, but these errors were encountered: