0

I'm using the Websocket-Sharp library to make a client connection to an existing socket service.

My client code has this:

using (var ws = new WebSocketSharp.WebSocket("wss://localhost"))
{
    ws.OnMessage += (sender, e) => Console.WriteLine("Received: " + e.Data);

    ws.Connect();
    ws.Send(myByteBuffer);
}

When the .Connect() call is made, it hits a breakpoint in my service code. The buffer payload contains some payload that looks like a handshake payload but I'm not sure how to decode this.

The buffer has a length of 113 and has an output of this:

[0]: 22
[1]: 3
[2]: 1
[3]: 0
[4]: 108
[5]: 1
[6]: 0
[7]: 0
[8]: 104
[9]: 3
[10]: 1
[11]: 93
[12]: 167
[13]: 1
[14]: 205
[15]: 150
[16]: 142
[17]: 39
[18]: 230
[19]: 167
[20]: 52
[21]: 174
[22]: 70
[23]: 22
[24]: 9
[25]: 114
[26]: 33
[27]: 155
[28]: 53
[29]: 94
[30]: 87
[31]: 212
[32]: 71
[33]: 71
[34]: 107
[35]: 172
[36]: 202
[37]: 248
[38]: 191
[39]: 215
[40]: 29
[41]: 156
[42]: 98
[43]: 0
[44]: 0
[45]: 14
[46]: 192
[47]: 10
[48]: 192
[49]: 9
[50]: 192
[51]: 20
[52]: 192
[53]: 19
[54]: 0
[55]: 53
[56]: 0
[57]: 47
[58]: 0
[59]: 10
[60]: 1
[61]: 0
[62]: 0
[63]: 49
[64]: 0
[65]: 0
[66]: 0
[67]: 14
[68]: 0
[69]: 12
[70]: 0
[71]: 0
[72]: 9
[73]: 108
[74]: 111
[75]: 99
[76]: 97
[77]: 108
[78]: 104
[79]: 111
[80]: 115
[81]: 116
[82]: 0
[83]: 10
[84]: 0
[85]: 8
[86]: 0
[87]: 6
[88]: 0
[89]: 29
[90]: 0
[91]: 23
[92]: 0
[93]: 24
[94]: 0
[95]: 11
[96]: 0
[97]: 2
[98]: 1
[99]: 0
[100]: 0
[101]: 35
[102]: 0
[103]: 0
[104]: 0
[105]: 23
[106]: 0
[107]: 0
[108]: 255
[109]: 1
[110]: 0
[111]: 1
[112]: 0

Does anyone know how I can decode this and handle this? I assume it's a standard handshake message that needs to be handled but I can't work out how to do it correctly.

Thanks in advance

millie
  • 2,642
  • 10
  • 39
  • 58
  • 2
    You need to get the specification of the data. There are some stings like tlocalhost in the data, but most of the data in non printable characters. – jdweng Oct 16 '19 at 12:12
  • @jdweng what do you mean specification of the data? I've not explicitly sent anything on the socket yet. All I've done is call the .Connect() which should just be opening the socket. – millie Oct 16 '19 at 12:46
  • You are connecting to a device. The device should have a specification on format of the data. – jdweng Oct 16 '19 at 13:11
  • @jdweng I'm running the client program and the server program on the same computer. They are both .Net apps. – millie Oct 17 '19 at 16:24
  • I makes absolutely no difference if the client and server on same machine or different machines. You cannot decode data that you only know the length and not the description of each field. – jdweng Oct 17 '19 at 16:42

0 Answers0