Login Page - Create Account

Support Board


Date/Time: Sun, 19 Jan 2025 15:02:27 +0000



Post From: Google Protocol Buffers not working

[2018-04-11 07:29:05]
User942837 - Posts: 108
Thank you for your reply. Yes I suspected that this wasn't the issue however at least now I know I have the correct proto3 file.

This line indicates that Sierra Chart received zero bytes from your client:
DTC client #6. 127.0.0.1 | No activity on network socket. Closing network socket. Bytes in receive buffer: 0 | 2018-04-10 09:23:47

So it actually did not send any data to Sierra Chart.


I've been trying many ways to connect to Sierra using the Google Protocol buffers but I am not yet to a stage where I am connecting.

I am definitely sending data to sierra but receiving no sort of error which tells me that either it is not being sent in the right format or some other reason. I am using same code that I am using to send a JSON message and have also tried using the WriteTo method but to no avail.

I know that you do not usually help in client code which is not the reason for sending this message but perhaps from your experience you could tell me what's the best way to write the bytes to Sierra DTC. These are the 3 versions I have tried. I initially also had a similar issue when communicating via JSON but this was solved by sending a null terminator but in this case I have no idea what to try next.
I would appreciate any help to identify what the problem might be as sierra is not reporting anything so I have no idea what I am doing wrong. Thanks a lot.

LogonRequest message = new LogonRequest();
message.HeartbeatIntervalInSeconds = 5;
message.ClientName = "Sample";
message.TradeMode = TradeModeEnum.TradeModeDemo;
message.HeartbeatIntervalInSeconds = 5;

    //Version 1) using WriteTo directly on the message and also tried WriteDelimitedTo which writes length and then data to the stream

TcpClient client = new TcpClient(ipServer, port);
var stream = client.GetStream();

// Send the message to the connected TcpServer.
var calculateSize = message.CalculateSize();

message.WriteTo(stream); // or using WriteDelimtedTo(stream)


    Version 2) Using CodedOutputStream

TcpClient client = new TcpClient(ipServer, port);
var stream = client.GetStream();

//Create Coded output stream to send data over the tcp client
CodedOutputStream cod = new CodedOutputStream(stream);

// Send the message to the connected TcpServer.
var calculateSize = message.CalculateSize();

message.WriteTo(stream);

    Version 3) Getting byte array for Google Proto to byte array and sending it.

byte[] bytes = message.ToByteArray();

// Send the data through the socket.
int bytesSent = dtcSocket.Send(bytes);
Date Time Of Last Edit: 2018-04-11 07:44:05