Json-rpc response version number

132 views
Skip to first unread message

V DG

unread,
Apr 3, 2022, 9:17:10 AMApr 3
to JSON-RPC
I'm implementing a json-rpc server, responding to json-rpc versions 1.0 or 2.0

I have a question about the "jsonrpc" element of the response:

The full request received is first parsed as json, and then analysed as a json-rpc request.  If the parsing phase fails (invalid syntax for example), the server don't have any workable request.

The server than has to respond with a parser error response. 

But how could the server know the "jsonrpc" value to send in the response ? It could be nothing (not a json-rpc 2.0 request) or a valid "jsonrpc" "2.0" response ?

Examples in the json-rpc 2.0 specifications ( rpc call with an empty Array, rpc call Batch  invalid JSON, ... ) seems to "force" a json-rpc 2.0 response.  Why ?

Thank you for your reply

VDG

George Georgalis

unread,
Apr 4, 2022, 12:27:21 PMApr 4
to json...@googlegroups.com
invalid json
or
unrecognised json-rpc version
in the default version of the server?


--
You received this message because you are subscribed to the Google Groups "JSON-RPC" group.
To unsubscribe from this group and stop receiving emails from it, send an email to json-rpc+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/json-rpc/e65433ba-dd36-43ac-ab7d-33301221bb70n%40googlegroups.com.


--

Andrew Arnott

unread,
Apr 4, 2022, 12:27:21 PMApr 4
to json...@googlegroups.com
If the request fails to even parse as valid JSON, the client or connection is badly broken and I wouldn't bother returning a response message at all. Even if the client could parse it, they might not be able to follow-up with another message, depending on how the message boundary is formed between their first and second message.
I would just 'hang up' as a server on the client.

--
Andrew Arnott
"I may not agree with what you have to say, but I'll defend to the death your right to respectfully say it. And I hope you will return the courtesy when the time comes." - my own twist on S. G. Tallentyre


From: json...@googlegroups.com <json...@googlegroups.com> on behalf of V DG <dev.en...@gmail.com>
Sent: Sunday, April 3, 2022 2:41 AM
To: JSON-RPC <json...@googlegroups.com>
Subject: [json-rpc] Json-rpc response version number
 
Reply all
Reply to author
Forward
0 new messages