Re:The Hidden Complexity of Scaling WebSockets
by melchizedek6809 on Saturday January 25, 2025 @06:44AM
(#42821078)
Why can't the server send unsolicited messages in JSON-RPC?
I've implemented bidirectional JSON-RPC in multiple projects and things work just fine, even going as far as sharing most of the code.
Re:The Hidden Complexity of Scaling WebSockets
by crabmusket on Saturday January 25, 2025 @08:29AM
(#42821521)
Yep, the web server and client can both act as JSON-RPC servers and clients. I've used this pattern before too with Web Workers, where the main thread acts as both client (sending requests to the worker) and server (fielding requests from the worker).
JSON-RPC is request-response only; the server cannot send unsolicited messages. gRPC supports bidirectional streaming, but I understand that setting it up is more complex than WebSockets.
I will concede that horizontal scaling of RPC is easier because there's no connection overhead.
Ultimately, it really depends on what you're trying to build. I also don't underestimate the cultural aspect; fair or not, JSON-RPC feels very "enterprise microservices" to me. If you think in schemas, RPC might be a good fit.