RTC Forums
April 27, 2024, 09:47:13 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: json-rpc 2.0 request paramteres order  (Read 6835 times)
Max Terentiev
RTC License
***
Posts: 49


« on: June 26, 2017, 11:58:17 AM »

Hi, Danijel !

I have problems with json-rpc 2.0 requests generated by PHP function "json_encode".

This function generate json object like this (looks like parameters in alphabetical order):

{"jsonrpc":"2.0","id":1,"method":"engineGetStatus","params":[]}

While your implementation expect this:

{"jsonrpc":"2.0","method":"engineGetStatus","params":[],"id":1}

I think request parameters order should be not important. So, this variants should be also valid:

{"id":1, "jsonrpc":"2.0","method":"engineGetStatus","params":[]}
{"method":"engineGetStatus","params":[],"id":1,"jsonrpc":"2.0"}
etc

As a quick fix a modify TRtcValueObject.json_checkFunctionType to:

Code:
if ( json_checkTag(RTC_QMETHOD,s,at2) or
                     json_checkTag(RTC_QPARAMS,s,at2) or
                     json_checkTag(RTC_QID,s,at2) )then // added this line
                  Result:=rtc_Function;   

But it's not a final solution. It's only handle requests where "id" is second paramter.

Hope you can fix it in next version.

Thank you !
Logged
Max Terentiev
RTC License
***
Posts: 49


« Reply #1 on: June 26, 2017, 01:02:54 PM »

And one addition: if your parser does not recognize request as json-rpc request (rtc_Function) they should send back some error like "invalid json-rpc request".
Instead they send back just nothing.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: June 26, 2017, 02:46:15 PM »

Thanks. I'll add your proposed fix for PHP in the next RTC SDK update. Let me know if you bump into any other problems.

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: June 28, 2017, 11:25:07 AM »

I've released RTC SDK v8.15 now to fix the "JSON-RPC 2.0" parser, so it will recognize remote function calls received from PHP using "json_encode", where "id" is the 2nd element in a JSON record (directly following "jsonrpc":"2.0").

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: June 28, 2017, 05:35:38 PM »

I've now also released RTC SDK v8.16, which extends the "JSON-RPC 2.0" parser to also recognize and parse remote function calls and exception objects where "jsonrpc" is NOT the 1st element in the root JSON record. In other words, all of these JSON objects should now be recognized and correctly parsed as "JSON-RPC 2.0" remote function calls:

{"jsonrpc":"2.0", "method":"engineGetStatus", "params":[], "id":1}
{"jsonrpc":"2.0", "id":1, "method":"engineGetStatus", "params":[]}
{"id":1, "jsonrpc":"2.0", "method":"engineGetStatus", "params":[]}
{"id":1, "method":"engineGetStatus", "params":[], "jsonrpc":"2.0"}
{"method":"engineGetStatus", "params":[], "id":1, "jsonrpc":"2.0"}
{"method":"engineGetStatus", "params":[], "jsonrpc":"2.0", "id":1}

Best Regards,
Danijel Tkalcec
Logged
Max Terentiev
RTC License
***
Posts: 49


« Reply #5 on: July 03, 2017, 01:01:43 PM »

Thank you very much !
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 16 queries.