Azure / azure-relay-node

☁️Node.js library for Azure Relay Hybrid Connections
https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-what-is-it
MIT License
12 stars 15 forks source link

Receive incomplete data #13

Closed danny8002 closed 7 years ago

danny8002 commented 7 years ago

Actual Behavior

  1. onmessage event.data is not complete and it is just an piece of chunk

Expected Behavior

  1. onmessage event.data is the full set of data

Server Side, i copy the code from https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-hybrid-connections-dotnet-get-started

and it 'Send' a 4K text data as response.

Client Side, i use nodejs whis this package: ws.onmessage = function(event){ console.log('call'); let data: string; if (typeof event.data === 'string') { data = event.data; } else if (event.data instanceof Uint8Array) { data = new TextDecoder("utf-8").decode(event.data); } else { data = "invalid"; } console.log(data); }

and i found onmessage is called several times, and in every call, 'data' is one of parts of full text data that server sends.

Versions

danny8002 commented 7 years ago

according to WebSock RCF https://tools.ietf.org/html/rfc6455#section-5.2, I dig into the ws code, then i found every frame data have FIN = 1 which means it is the last frame. so maybe this issue happens in server which send every frame with FIN=1, i will continue to dig.

danny8002 commented 7 years ago

i have confirmed this issue happens in server side. and just put this issue in here in case other guys also get.