3 ms·
We use jsonrpc 2.0 over websockets, typescript + runtime type assertions using functional combinators at the i/o boundary, it's very fast, bi-directional, type
by mirekrusin 6y ago
We use jsonrpc 2.0 over websockets, typescript + runtime type assertions using functional combinators at the i/o boundary, it's very fast, bi-directional, type safe, pleasure to work with, easy to optimise (rpc call duration is easily captured), we know exactly the number of connected clients, it's easy to inspect outgoing buffer sizes, debounce notifications to do adaptive "throtthling" for people on slower networks etc. Above all, whole communication is uncomplicated and straight forward, lightweight. We tend to maintain client library by b/e team (maybe ~90% of code by b/e devs) for anything non trivial. The best documentation you can get is typed + jsdoc described library that you can just use. It is up to date. It's cheap to add new calls and notifications, it's easy to change apis where typescript guides you through changes required etc.
- jensneuse 6y agoThis is more or less the approach I'm taking with WunderGraph. There's just one exception. I'm not using websockets but simply a HTTP2 stream. Browsers have limitations regarding how many tcp connections you can open to the same origin and for each tab/window and websocket connection you have to open a new tcp connection. HTTP2 on the other hand can pipeline, depending on your browser, up to 200 streams over a single tcp connection, regardless of the tab or window. I've written a post on the topic: https://wundergraph.com/blog/deprecate_graphql_subscriptions_over_websockets https://wundergraph.com/blog/deprecate_graphql_subscriptions...
- mirekrusin 6y agoInternet says: "(...) The infamous 6 connections per host limit does not apply to WebSockets. Instead a far bigger limit holds (255 in Chrome and 200 in Firefox). (...)". We do single connection per session (tab/window), there's no need to have more.
- christophilus 6y agoDid you roll your own stack, or use an off the shelf toolkit? I’ve got something similar I’m wiring up right now in my project.
- mirekrusin 6y agoWe rolled our own.
- draw_down 6y agoSuper interesting approach, thanks for posting.