off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
gibb 2020-10-24T08:19:53.489100Z

How reliable is websocket transportation to the browser?

orestis 2020-10-24T08:21:01.491100Z

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

gibb 2020-10-24T08:21:10.491400Z

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.

gibb 2020-10-24T08:21:46.492100Z

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

gibb 2020-10-24T08:22:44.493Z

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

gibb 2020-10-24T08:23:34.494100Z

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.

orestis 2020-10-24T08:24:14.495900Z

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

gibb 2020-10-24T08:24:46.497Z

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

gibb 2020-10-24T08:26:08.498500Z

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

gibb 2020-10-24T08:26:11.498700Z

Or does the browser do that for me?

gibb 2020-10-24T08:26:25.499Z

I barely know what I don't know here ๐Ÿ˜„

orestis 2020-10-24T08:30:29.499600Z

Haha

orestis 2020-10-24T08:31:12.000700Z

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

gibb 2020-10-24T08:31:52.002300Z

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.

gibb 2020-10-24T08:32:16.003200Z

Maybe something like STOMP is a good enough protocol.

orestis 2020-10-24T08:32:22.003500Z

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.

gibb 2020-10-24T08:33:15.004400Z

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

gibb 2020-10-24T08:33:48.005100Z

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

orestis 2020-10-24T08:34:25.006200Z

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

gibb 2020-10-24T08:35:20.007900Z

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 ๐Ÿ˜„

orestis 2020-10-24T08:35:35.008700Z

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

gibb 2020-10-24T08:35:48.009200Z

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

orestis 2020-10-24T08:36:14.010400Z

Ah - I donโ€™t know a thing about grpc

gibb 2020-10-24T08:36:43.011400Z

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

gibb 2020-10-24T08:37:00.012300Z

And the streaming abstraction is not great for grpc

orestis 2020-10-24T08:37:13.012800Z

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

gibb 2020-10-24T08:38:30.013Z

Ah yeah interesting

orestis 2020-10-24T08:40:33.014Z

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

orestis 2020-10-24T08:40:42.014300Z

https://github.com/ptaoussanis/sente

gibb 2020-10-24T08:40:51.014600Z

That's neat yeah I've heard about sente

gibb 2020-10-24T08:41:55.015400Z

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 ๐Ÿ˜ƒ

orestis 2020-10-24T08:42:15.016Z

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

gibb 2020-10-24T08:45:00.017100Z

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

dominicm 2020-10-24T12:49:56.017300Z

Even new jira is absolutely infuriating.

orestis 2020-10-24T15:51:24.018900Z

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