JSON-RPC 2.0 over web sockets?

3,569 views
Skip to first unread message

Vladimir Dzhuvinov / NimbusDS

unread,
Mar 28, 2012, 7:04:06 AM3/28/12
to JSON-RPC
Hi guys,

Last week I attended a lecture by Peter Lubbers from Kaazing on the
merits of the new HTML5 web sockets. The benchmarks were impressive.

Has anyone attempted implementing a JSON-RPC over web sockets? Any
thoughts or experiences?

Vladimir

Matt (MPCM)

unread,
Mar 30, 2012, 9:17:20 PM3/30/12
to json...@googlegroups.com
I have not implemented anything beyond some local tests, but I feel json-rpc will be a great fit.

Being bi-direction, the same issues as working over traditional sockets exist, so a lot of those lessons are applicable.

If you get into it deeper, please post back with your experiences :)

--
Matt (MPCM)

Mo

unread,
Mar 31, 2012, 5:09:06 PM3/31/12
to json...@googlegroups.com
Long time lingerer on this mailing list, first time poster.

First off thanks for everyone's hard work on the JSON-RPC protocol. I not only like its simplicity but its extensability is really useful to me as well.

I figure now would be a good time to introduce my JSON-RPC implementation, RJR

https://github.com/movitto/rjr

It is implemented in Ruby (eventmachine) and serves JSON-RPC requests over a multitude of transport protocols, tcp/udp, http, websockets, amqp, and more.

It acts as a sort of Rosetta stone between these protocols, allowing generic handlers to be registered and then dispatched to whenever a request comes in on one of those transports.

I also supports various options features including generic message headers and callbacks, allowing both nodes to invoke JSON-RPC requests on each other, when a websocket connection is established for example.

Its a new project but is solid, I ship a full test suite for the server and ruby/javascript clients, as well as an integration / stress test. Documentation is a bit lacking, but I'll get to that eventually (unless someone gets to it first, patches are more than welcome!)

Any thoughts or opinions on the project would be more than appreciated!

Mo

unread,
Mar 31, 2012, 4:59:56 PM3/31/12
to JSON-RPC
Long time lingerer on this mailing list, first time poster.

First off, thanks for everyone's work on the JSON-RPC protocol. I not
only like its simplicity but its extensability is really useful to me
as well.

In any case, as far as $topic, I'd like to introduce my JSON-RPC
implementation RJR:

https://github.com/movitto/rjr


It is implemented in Ruby using event machine, and serves JSON-RPC
requests over a multitude of protocols including tcp/udp, http,
websockets, amqp, and more. It acts a sort of a rosetta stone between
these protocols, allowing JSON-RPC handlers to be registered after
which requests will be dispatched to those handlers regardless of the
transport mechanism which the request came in on.

It also supports setting generic message headers, and callbacks, so
that once a websockets connection has been established for example,
both endpoints may invoke JSON-RPC requests on the other until one of
them closes the connection.

Currently I also ship ruby and javascript clients as part of the
project, making connecting to the RJR server, a cinch.

The project is early in development, but is solid, I ship a full unit
test suite (implemented in rspec), an integration / stress test, and
unit tests verifying the javascript client. Documentation can probably
be shored up a bit, but I'll get to that eventually (unless anyone
gets to it first, patches are more than welcome!)


Eventually I might consider reimplementing this project in C for
performance and so as to including bindings so that handlers can be
written in ruby, python, java, or whatever other language, but for the
time being this serves my needs.

Any comments, thoughts, etc on RJR would be more than appreciated.

Mo

unread,
Apr 1, 2012, 6:28:12 AM4/1/12
to json...@googlegroups.com
Hey sorry about the spam, didn't realize new users had to be approved before posting.

In any case a couple more things about RJR. It is currently licensed under the AGPLv3+ a fairly restrictive Free Software License, but I'd be willing to license it under something more permissive like the MIT or BSD licenses down the road if there is enough interest in the project and making that happen.

If anyone wants to toss the ball around on some ideas about a pure-C JSON-RPC implementation shout out. I see some objective-C and C++ implementations of the list [1] but nothing in pure C (ideally something that can be leveraged by alot of languages via some bindings interface, ffi, swig, gobject, etc).

I'm envisioning something like Apache HTTPD. A robust central server that exists to serve JSON-RPC requests via a configurable backend worker management scheme, with many modules (mod_*) to serve as optional extensions for the json-rpc protocol. Stuff like

- mod_auth - supporting client authentication against configurable backends
- mod_cache - supporting caching json-rpc requests / responses for performance
- mod_ruby/mod_python/etc - support writing request handlers in multiple languages
- mod_broker - object broker support, where requests correspond to access to object managed by the server and the means to invoke methods on those objects
- mod_ns - support namespace in request methods
- mod_filter - automatic filtering and routing of messages depending on content + rules
- mod_amqp/mod_ws/mod_web/mod_tcp/mod_udp/mod_local/etc - support for an extensible number of transports
- mod_typeinfo - JSON-RPC request metadata API, retrieve expected types for parameters and return values
- mod_loadbalancer, mod_proxy, mod_qos - extended network related features

Obviously would be a bit of work but could potentially be something that became really popular. Thoughts?

  -Mo

[1] http://en.wikipedia.org/wiki/JSON-RPC#Implementations

Luis Montes

unread,
Apr 3, 2012, 3:45:27 PM4/3/12
to json...@googlegroups.com
I did an implementation on node.js here:


and a live demo here:


With a decent low-latency connection, and a browser that supports websockets, you should see a huge performance increase.

Luis



Vladimir

--
You received this message because you are subscribed to the Google Groups "JSON-RPC" group.
To post to this group, send email to json...@googlegroups.com.
To unsubscribe from this group, send email to json-rpc+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/json-rpc?hl=en.


Reply all
Reply to author
Forward
0 new messages