uWebSockets.js icon indicating copy to clipboard operation
uWebSockets.js copied to clipboard

Is it possible to pass a socket handle directly to uWS?

Open hunterloftis opened this issue 2 years ago • 28 comments

eg, something equivalent to handleUpgrade.

The reason this is useful is that, combined with passing socket handles across processes, you can route all sockets based on the same topic to the same process in a node cluster:

  • https://nodejs.org/api/child_process.html#example-sending-a-socket-object

hunterloftis avatar Jul 20 '22 14:07 hunterloftis

This was asked before here: https://github.com/uNetworking/uWebSockets.js/issues/649

That guy was trying to do 1 socket per process which was a bad idea, your use case makes more sense but is not possible with uWS.js from what I understand, that is a Node socket feature

e3dio avatar Jul 20 '22 14:07 e3dio

That's what it looked like to me too, just wanted to check. Thanks for the quick reply @e3dio!

hunterloftis avatar Jul 20 '22 14:07 hunterloftis

It's still a good feature request

ghost avatar Jul 20 '22 14:07 ghost

I'm closing this, it's not a bad idea but it is a too complex idea for the gain - just let sockets fall wherever they fall and use the pub/sub or direct connections based on some URL query value or something like that. Point is - you can achieve pretty good results without this kind of low level hackery. But yes it is a good idea. But no, I have no time to implement and maintain this edge case (and it kind of goes against the simple nature of uWS)

uNetworkingAB avatar Dec 28 '22 14:12 uNetworkingAB