Client <> Server role clarification

171 views
Skip to first unread message

Mathieu

unread,
Dec 8, 2021, 2:59:21 PM12/8/21
to JSON-RPC
Hi,

I would like to clarify something about JSON-RPC protocol.

The protocol say's:

The Client is defined as the origin of Request objects and the handler of Response objects.
The Server is defined as the origin of Response objects and the handler of Request objects.

So as I understand there is no pre-defined role on a peer ?

Is it possible for a peer to be client and server (according to JSON-RPC specifications) ?

Imagine this example:

[Application A] ------------- [ IOT Gateway Daemon ]  ---------- [ RF Dongle ] --- [IOT Actor/Sensor]

The application communicate with a "IOT Gateway Daemon" using JSON RPC.
The "IOT Gateway Daemon" wait for request from "Application A" to send request to the "IOT Actors" (like wall socket..) (gateway role)

But now, if the "IOT Gateway Daemon" can receive messages from the IOT Sensors (temperature sensor). Is this service allowed to transmit notifications to the application according to JSON-RPC protocol ?

If yes:
- It means that a peer can act as a server and client (in terms of JSON-RPC) (which is good)

If not:
- why not ?

Bests regards,

David Ellis

unread,
Dec 8, 2021, 3:38:50 PM12/8/21
to JSON-RPC
Hi Mathieu,

The specification doesn't really define the term peer (though it does make a reference to peer-to-peer communication), so I see absolutely zero reason why you can't have the same executable as both a client and a server (and I have done that myself in the past); it's just acting as one or the other depending on context.

David

Matt (MPCM)

unread,
Dec 14, 2021, 8:55:37 AM12/14/21
to JSON-RPC
As David posted, ... but to go even further:

"One implementation of this specification could easily fill both of those roles, even at the same time, to other different clients or the same client. This specification does not address that layer of complexity."

An execution of code becomes a "client" or "server" based on what it is doing with/around those request/response objects.

Reply all
Reply to author
Forward
0 new messages