Skip to content
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

Question: remote socket + event emitter ? #458

Open
fxi opened this issue Jun 23, 2022 · 2 comments
Open

Question: remote socket + event emitter ? #458

fxi opened this issue Jun 23, 2022 · 2 comments
Labels
question Further information is requested

Comments

@fxi
Copy link

fxi commented Jun 23, 2022

Hello,

Would it be possible to have/recreate a full Socket from fetchSockets instead of the partial RemoteSocket ? Currently, if the socket is not local, it lacks some EventEmitter methods and it's is blocking for a specific case on a cluster.

Maybe I missed something :/

Thanks

@darrachequesne
Copy link
Member

@fxi you mean, having the on() method and such? In that case, that's not currently possible.

What you can do is use the serverSideEmit() method: https://socket.io/docs/v4/server-instance/#serversideemit

@darrachequesne darrachequesne added the question Further information is requested label Jun 26, 2022
@fxi
Copy link
Author

fxi commented Jun 26, 2022

Yep, thanks.

That's exactly that : I was trying to catch an event from a non-local socket. It was not clear for me that on/once were not available on remote socket: during testing, I was on a single node. On multiple nodes, local sockets are complete but remote sockets are partial.

I was mixing HTTP request to launch a process and websocket to feedback progress and listen for data from the browser in an optional async task.

I started converting everything using websocket/socket.io, including authentication. That's a consequent change, but it will simplify the whole thing.

I also got a sticky session issue in the first place: our proxy/load-balancer only allows cookie based stickiness, and it does not work when cookies are not allowed. ws connection were kept on the same server as the ws connection, but subsequent request were done on any node. It's basic, but after reading the doc, I was convinced that fetchSockets and redis-adapter were the solution.

Anyway, thanks again !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants