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

[Feature Request] WebSocket #45

Closed
Disinterpreter opened this issue Nov 20, 2020 · 1 comment
Closed

[Feature Request] WebSocket #45

Disinterpreter opened this issue Nov 20, 2020 · 1 comment

Comments

@Disinterpreter
Copy link

Disinterpreter commented Nov 20, 2020

Good day! I know that WebSocket not in your documentation. But I suggest to implement it.
I think that implementation of WebSocket will make connectivity between bots and mtproto better.

For example Discord messenger works on WebSocket for requesting data. And it can realize many features for big servers faster than it can be in longpoll (I'm not sure about webhook).

And don't forget that beautiful implementation of WebSocket is simpler for newbies, than webhook or long polling.

@levlam
Copy link
Contributor

levlam commented Nov 20, 2020

WebSocket interface would be harder to implement, especially for newbies, because you would need to introduce the whole new protocol atop WebSockets, which has update delivery confirmation. We can't afford to store updates after they are successfully delivered to bots, so there must be an explicit delivery acknowledgement support in the protocol. Discord doesn't have that, so every bot, which doesn't want to lose updates all the time, must have a database to store sequence number of the last processed update. The other WebSocket problem is that you must check the connection aliveness all the time to notice broken connections fast. Discord introduced Heartbeating just for that. Also, to minimize payload size Discord introduced per-payload compression. All of this is available by default through HTTP.

WebSocket protocol also has some advantages, like the absence of request/response headers and absence of ping time latency between updates (only comparing to getUpdates). But the size of the headers is neglible when compared to the payload size and ping time can be easily reduced to a neglible value. More over, you can now run Bot API server on the same server your bot runs, making all this WebSocket advantages completely useless.

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