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

Can the websocket connection be reused? #3

Open
kokjinsam opened this issue Jul 1, 2024 · 3 comments
Open

Can the websocket connection be reused? #3

kokjinsam opened this issue Jul 1, 2024 · 3 comments

Comments

@kokjinsam
Copy link

Hello there,

I notice that a new websocket connection is created for each channel. I was just wondering if there's any technical / other reason for not reusing the websocket connection.

@superchris
Copy link
Member

The underlying websocket connection is managed for us by Phoenix Channels javascript client, so I'm not sure whether this would be viable or not, TBH. I haven't peeked under the covers in the phoenix code to see whether you could get to the websocket connection there or not, but feel free to have a go and submit a PR if something useful comes of it.

@kokjinsam
Copy link
Author

I briefly looked at Phoenix client. I may be wrong but I don't think it handles socket connection pooling. One idea I have is to let user instantiate their own socket instance and remove https://github.com/launchscout/phx-live-state/blob/main/src/LiveState.ts#L89-L92. So changes would be minimal. What do you think?

@superchris
Copy link
Member

Hey sorry for slow reply, for some reason GH didn't notify me of your reply :( Anyways, I think letting the user pass in their own instance and creating one for them if they don't would be totally reasonable. That way you can pass one if you have one, if not LiveState will create it as before.

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

No branches or pull requests

2 participants