json rpc android,Android JSON-RPC tunneled in websocket

法兴德
2023-12-01

That's a pretty specific thing to "support". Websockets are just a bi-directional communications protocol implemented over HTTP (the HTTP part of the request does an "upgrade" to allow the TCP socket to be reused, in much the same way as HTTPS).

How?

Just pick any implementation of Websockets for Android that you're comfortable with. Perhaps Autobahn ?

To "tunnel" JSON-RPC over that, for example, you could sub-class the JSONRPCClient class in android-json-rpc (overriding the doJSONRequest method in much the same way JSONRPCHttpClient does) naming your implementation JSONRPCWebsocketsClient (to make use of whichever Websockets implementation you chose).

Why?

A more important question would be why you need to tunnel JSON-RPC over Websockets?

Are you going to use the (asymmetric, server-to-client) "notification" messages from the older JSON-RPC proposals? (I would!)

Are you stuck talking to some very specific server-side implementation?

Is this just to get past some silly corporate firewall?

If it's just for "notification" messages, then why not do this over plan TCP (more lightweight) rather than Websockets (which are significantly more complicated).

If it's to work with some specific server implementation, your options are "live with it" or to put a proxy server of some sort in between your clients and the server.

If it's to make use of HTTP to bypass a corporate firewall (perhaps in combination with needing server-to-client "notification" messages) then while this might be a "good" solution, an easier one might be to actually get support from ITS within said corporation to expose a secured, well-known endpoint without whatever restrictions are currently holding you back.

 类似资料:

相关阅读

相关文章

相关问答