New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
binary data is not transmitted entirely #895
Comments
Hi, const wss = new WebSocket.Server({
perMessageDeflate: false,
port: 8080
}); With current version (1.1.1) you can also pass a readable stream to We are currently discussing if this feature should be removed and let the developer handle this, see #875 (comment). The added benefit of the example posted there is that backpressure is correctly handled. Please note that it doesn't work with 1.1.1 as the
|
Thank you for responding. After further investigation, I found that the server is in fact sending the correct number of bytes, and the issue is in fact in the browser, where the audio data is stored in memory and some of the bytes are word-aligned, and I have to unpack the data. I have posted this on stackoverflow for additional help. http://stackoverflow.com/questions/40657827/ Sorry for suspecting that the issue was with your code. |
@raminrad why are you using the binary encoding in Those chunks are then converted to buffers using the utf-8 encoding in TL;DR try to remove the |
You are absolutely right! I switched to a different Web Socket node package and the person on stack overflow suggested that I pass the 'binary' encoding to |
You have to send binary data so there is no reason to convert each chunk to a string and then back to a buffer again when sending the data. The added benefit of using buffers directly is that performance is better. In your use case you are sending data from server to client so that data doesn't need to be masked. You have the best possible scenario where data is a buffer and doesn't need to be copied :) P.S. I looked at the SO post and noticed this line conn.sendBytes(new Buffer(data)); You can avoid creating a new buffer from a buffer as that is only a useless copy. Closing this, please comment or reopen if needed. |
I am using WS version 1.1.1 and sending audio data (raw PCM) to a browser. But the number of bytes I receive on the client side (after I reassemble all the data in WS messages) is not equal to the original file size (in bytes). I am not sure if this is an issue with the code or the way I am using it.
The text was updated successfully, but these errors were encountered: