-
Notifications
You must be signed in to change notification settings - Fork 700
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
Make defaults for socket.io transports consistent to use polling before websocket #202
Conversation
So, as mentioned in the IRC, I don't think we should do this. The reason it does this is so that if you can't establish websockets because of network issues, you are still connected from straight away. If you don't, you can have up to 30 seconds without a connection to the server. |
Just for the record, here is the IRC discussion you guys had (I had to dig up my 600+ unread messages, thanks for mentioning you discussed about it, @YaManicKill :-) ):
Also, another FYI, this feature/setting was added by erming/shout#267. First, I agree that whatever the choice is, defaults and fallbacks should match. That being said, there are a few key questions to answer here:
|
No, polling doesn't stop websockets happening, it just means that the first few requests are a bit slower than if they were over websockets. But because websockets takes more setup, they still happen quicker, and once websockets is set-up, it switches over to that
There is 1 case that this can fail completely, which I have come across before. If websockets are blocked on the network level (on specific port or just entirely) then it can take up to 30 seconds for socket.io to realise that you haven't connected, and try polling instead/
It's not about browsers, it's about the networks. You can be on the latest everything, but at work websockets are blocked (it has happened on a project I worked on) then you have a long time without any connection, and it can seem like it's entirely broken. Setting up polling first means that everyone is connected from the get-go. Then socket.io immediatelly tries to set up websockets, and if it connects, then it turns off polling and switches to the websocket connection. I see no reason to switch this around, as it doesn't slow anything down, and can massively speed it up for some people. |
Thanks a lot for this explanation, @YaManicKill, it makes complete sense. @xPaw, unless there is something I misunderstood, I think I agree with @YaManicKill here. What do you think of having consistent defaults and fallbacks? |
@astorije I will rebase the PR later to change the fallback to match default config. |
Rebased. |
👍 |
👍 and merging. Thanks! |
Change default socket.io transports to use websocket over polling
Since we chose to support modern browsers, we should be just fine defaulting to websockets, if the browser does not support them, it will fallback to http polling.
Code already defaults to this order here: https://github.com/thelounge/lounge/blob/f577da52a39d118c9f6256101a7cd3828dcfc67d/src/server.js#L28