Fork me on GitHub
#off-topic
<
2020-10-24
>
gibb08:10:53

How reliable is websocket transportation to the browser?

orestis08:10:01

As reliable as any other TCP connection. What are you trying to do?

gibb08:10:10

I'm not really clear on how a web sites gets access to TCP transportation, but I'm assuming it's via some kind of sandbox that the browser contains.

gibb08:10:46

I'm trying to decide if streaming to the browser is even a good idea, or if I should stick to polling things.

gibb08:10:44

I have this application that renders a 3d environment and the entities' position within this environment is constantly updating.

gibb08:10:34

So say I have for example 3000 entities moving around and they each have an x, y, z coordinate and a few bytes of metadata on them.

orestis08:10:14

Web sockets should have a lower overhead as doing http polling will have overhead of headers, cookies etc.

gibb08:10:46

I need something like retry logic and in band keep-alives right?

gibb08:10:08

Because I won't be able to access TCP keepalive or similar things inside the browser right?

gibb08:10:11

Or does the browser do that for me?

gibb08:10:25

I barely know what I don't know here 😄

orestis08:10:12

Yes you need your own retry logic, and keep alive. Honestly I’d use a library that handles those for me.

gibb08:10:52

Yeah I'm looking at something like that. We've tried grpc-web but the streaming logic was leaking all over the place and you barely need it for the backend where you can use HTTP2.

gibb08:10:16

Maybe something like STOMP is a good enough protocol.

orestis08:10:22

An alternative worth considering is using SSE which is push only (not bidirectional) and handles retry and keep alive. But it’s a more obscure tech, albeit simpler.

gibb08:10:15

Yeah I've actually looked into that quite a bit and even built a grpc http2 stream -> sse http1.1 proxy thingamajig, but the handing of retries and such was a bit off

gibb08:10:48

I still needed in-band keepalives to make sure the browser really understood if it had lost the connection in all cases.

orestis08:10:25

Yeah then websockets is probably the browser tech to use. You can have your own ACK logic etc.

gibb08:10:20

It would be interesting / terrifying to understand the differences between browsers and socket handling as well but I am frankly disgusted by the prospect of learning that stuff and then having the Chrome team pull my rug out from under me 😄

orestis08:10:35

Http2 is unrelated, no? I don’t think it handles your use case.

gibb08:10:48

Yeah it's just that grpc is built on top of http2

orestis08:10:14

Ah - I don’t know a thing about grpc

gibb08:10:43

Sorry it was a bit out of context there - it's an argument against streaming grpc between backend services since due to their HTTP2 nature the request response is pretty efficent anyway

gibb08:10:00

And the streaming abstraction is not great for grpc

orestis08:10:13

The only downside about websockets that I’ve seen in the wild is some corporate frameworks silently blocking them.

gibb08:10:30

Ah yeah interesting

orestis08:10:33

So libraries like http://socket.IO or sente give you an API that will fall back to long polling.

gibb08:10:51

That's neat yeah I've heard about sente

gibb08:10:55

The gentlemen building the frontend in question have chosen angular to build their application (yes I'm interested in another job...) so I'll have a look at what they can use from there easily 😃

orestis08:10:15

http://Socket.IO is the leading js framework i think.

gibb08:10:00

Thanks for the discussion @orestis I really appreciate having someone to geek out about over web protocols at 10:44 in the morning on a saturday 😄 Much love and have a great weekend

orestis15:10:24

Thanks it was nice geeking out too :) I had to run so I dropped off.

dominicm12:10:56

Even new jira is absolutely infuriating.