DTC Protocol Discussion Forum
- DTC Protocol Discussion Forum |
- Search Board |
- Control Panel |
- View My Posts / Threads |
- Direct Messages
Date/Time: Fri, 29 Nov 2024 16:37:14 +0000
DTC with JSON encoding
View Count: 4869
[2017-12-22 15:06:03] |
Jose - Posts: 4 |
Hello, Please help me because in the past two days I tried to solve JSON communication (from .NET C#) with DTC but in this moment I feel myself in an infinitive circle. In SierraChart I set the DTC server encoding to JSON (with authorization is not required). Related to this "Connection and Logon Sequence" description: (DTC Messages and Procedures: Connection and Logon Sequence) "If the Client knows the default encoding used by the Server, then it does not need to send an ENCODING_REQUEST message to the Server but it is preferred." ...for me it means I can skip the encoding part and I can step forward (to the point 3.)) to the LOGON_REQUEST. My LOGON_REQUEST JSON text is this: {"Type":1,"HeartbeatIntervalInSeconds":5,"TradeMode":1,"ClientName":"Jose"}
Is it okay or something is missing from it?Originally .NET framework has the "Encoding.BigEndianUnicode" support but the DTC server is waiting for the message in "LittleEndian" encoding. I have found some interesting articles in this topic and if I understand well the differences between LittleEndian and BigEndian depends on my hardware. I have checked my computer architecture and that is LittleEndian (https://msdn.microsoft.com/en-us/library/system.bitconverter.islittleendian.aspx). ...so I think my message encoding is correct. I sent all JSON messages with this encoding but however anything what I sent to DTC server then I got this error message: DTC client #1. 127.0.0.1 | Received message with an invalid size (1). | 2017-12-22 14:12:06 * Can you help me what am I doing wrong? Thanks in advance! Jose |
[2017-12-23 06:03:53] |
DTC Engineering - Posts: 320 |
Each JSON message needs to be encoded using 8-bit characters and needs to be null-terminated. Big endian and little endian is not relevant here. Unicode is not supported. {"Type":1,"HeartbeatIntervalInSeconds":5,"TradeMode":1,"ClientName":"Jose"} As long as according to the documentation all of the fields which are required or you want to specify are included, then it is OK.
Date Time Of Last Edit: 2017-12-28 02:29:45
|
[2017-12-28 02:29:02] |
DTC Engineering - Posts: 320 |
We would like to know if post #2 was helpful and resolved the issue?
|
[2017-12-29 02:42:04] |
Jose - Posts: 4 |
Yes, it was very-very helpful! Thank you so much!!! ...especially these words saved me: needs to be null-terminated :) Firstly I tried without ending char, after I used \n and \r\n but these could not help. Somehow I totally forgot the null-terminated string existence. Originally I encoded in UTF-8 but because of the unsuccessful tries I started to play with the different encodings, so this mixed me totally. Now with \0 ending in UTF-8 encoding everything works well! Thank you again! ps.: Sorry for the late answer, it happened just because of the Christmas holiday :) I wish you happy holidays and a Perfect New Year!!! Date Time Of Last Edit: 2017-12-29 02:43:29
|
[2017-12-29 02:48:59] |
DTC Engineering - Posts: 320 |
This is good. Happy holidays and new year. |
[2017-12-29 02:55:31] |
Jose - Posts: 4 |
Thank you!
|
To post a message in this thread, you need to log in with your Sierra Chart account: