Date/Time: Fri, 19 Oct 2018 10:28:28 +0000
Post From: DTC Protocol
|User783015 - Posts: 7|
This is exactly what I was looking for (the binary representation of the encoding request message):
// Encoding request is: 16 0 6 0 7 0 0 0 4 0 0 0 68 84 67 0
This is the method I'm using in my Python client to send the encoding request to Sierra Chart:
# Send encoding request to the server
def encoding_request( self ):
# The encoding request must be sent in a binary format
message = struct.pack( "<2H2i4c" , 16 , ENCODING_REQUEST , DTC_PROTOCOL_VERSION , JSON_ENCODING , 'D' , 'T' , 'C' , chr( 0 ) )
print( "Sending encoding request message" )
self.dtc_socket.sendall( message )
I was expecting to get a response in the binary format as well, instead of that I got a JSON response already:
Sending encoding request message
Server encoding response:
Is this expected? The DTC protocol documentation website (http://dtcprotocol.org/index.php?page=doc/doc_DTCMessageDocumentation.php#EncodingRequest) states:
In either case, the ENCODING_RESPONSE is sent using the encoding the ENCODING_REQUEST was sent using, which must be Binary Encoding if it is the first message at the beginning of the network connection. All subsequent messages are sent using the new encoding if it was accepted by the Server.
I'm more than happy parsing the JSON response rather than the binary message. On the other hand there seems to be an inconsistency between Sierra Chart DTC server behavior and the DTC protocol specification ;)
UPDATE: I spent significantly more time on this today and my code is shaping up pretty well. I have one additional question though: Sierra Chart exposes two DTC servers - one for historical data on port 11098 and one for real-time data on port 11099. These two DTC servers behave differently in regard to the ENCODING_RESPONSE message which I mentioned above. HD server responds to my initial JSON encoding request in binary encoding (expected according to DTC protocol definition), the second on 11099 responds to my initial JSON encoding request in JSON encoding (the inconsistency I reported above).
I have updated my client side code to detect the encoding of the ENCODING_RESPONSE message and process it accordingly.
The HD server is giving me a logon error "Username not specified" which I'll read about a bit more - I guess the historical data DTC server requirements are different than for the real-time data service (which returns logon success even if I don't specify any credentials).
Date Time Of Last Edit: 2016-03-27 21:29:14