By Robin Pulkkinen on Tuesday, 17 December 2019
Posted in Support
Likes 0
Views 1.8K
Votes 0
Hello!

I'm new user. I might be doing something wrong.
I 'm trying to create websocket client with Delphi XE using jsonrpc 2.0
JsonClass is TsgcJSON. Componets in form are "TsgcWebSocketClient" and "TsgcWSPClient_sgc"

code:
js := TsgcJSON.Create(self);
js.AddPair('jsonrpc','2.0');
js.AddPair('id','pos-'+IntToStr(IDnum));
js.AddPair('method','Status');

Pps := TsgcJSON.Create(self);
Pps.AddPair('timestamp',FormatDateTime('yyyy-mm-dd', Now)+'T'+FormatDateTime('hh:nn:ss.ssss', Now)+'Z');
Pps.AddPair('api_key','abcabc');

js.AddObject('params',pps.Text);

Messag := Js.Text;
messagesLog.Lines.Add(Messag);
answer := wsclient.WriteAndWaitData(Messag,600);

Data send:
{"jsonrpc":"2.0","id":"pos-1","method":"VersionInfo","params":{"timestamp":"2019-12-17T13:54:04.04Z","api_key":"apcabc"}}

I get correct answer from server, but I also get error and disconnecting:

#RawMessage:{"jsonrpc":"2.0","method":"_CloseReason","params":{"error":{"code":-32600,"message":"received result for id which was not requested","data":{"string_code":"JSONRPC_INVALID_REQUEST","details":"JSONRPC_INVALID_REQUEST: received result for id which was not requested\n at JsonRpcWebsocket.onDataJson (/src/JsonRpc.js:173:37)\n at WebSocket.JsonRpcWebsocket.stream.on (/src/JsonRpcWebsocket.js:15:22)\n at emitOne (events.js:116:13)\n at WebSocket.emit (events.js:211:7)\n at Receiver.receiverOnMessage (/src/node_modules/ws/lib/websocket.js:800:20)\n at emitOne (events.js:116:13)\n at Receiver.emit (events.js:211:7)\n at Receiver.dataMessage (/src/node_modules/ws/lib/receiver.js:423:14)\n at Receiver.getData (/src/node_modules/ws/lib/receiver.js:353:17)\n at Receiver.startLoop (/src/node_modules/ws/lib/receiver.js:139:22)"}}}}

in the logfile my Sendings look odd: Sent 17.12.2019 13:54:04: ?? ??d??oF??aI?iF?O?J?O?FO?

Any Idea?

Regards,

Kirsi
View Full Post