node-json-socket icon indicating copy to clipboard operation
node-json-socket copied to clipboard

'message' event doesnot work if server part is implemented on C#

Open keepitsimple opened this issue 9 years ago • 2 comments

keepitsimple avatar Mar 16 '15 16:03 keepitsimple

Could you provide some more info please? Suggested fix?

sebastianseilund avatar Mar 20 '15 18:03 sebastianseilund

I ran into this issue too but was able to solve it. I think it's because of lack of documentation. Once I looked at how your library functioned I saw the bug in my server.

When your server writes data back to the socket you have to append your json with length + '#'. Otherwise the library didn't know how big the buffer was.

var buffer = Encoding.UTF8.GetBytes(string.Format("{0}#{1}", json.Length, json));
socket.Send(buffer, SocketFlags.None);

buddyfavors avatar Nov 14 '15 17:11 buddyfavors