Pipe websocket message to file #5835
Replies: 1 comment
-
Posted at 2017-11-20 by @gfwilliams You can't pipe one big message in I'm afraid - not least because you'd have to be able to parse the stream of JSON. You could however send a series of smaller messages? Eg:
It might help to have an acknowledgement sent back as well, so you can throttle sends. Chunking everything into 512 bytes of data would work well since that's the allocation unit size. You could also speed things up a bit by sending raw binary data (or even base64 in a string) rather than JSON (which has to be parsed). Or, you could probably make things work a bit more smoothly doing something like this:
as it wouldn't then block the event loop for quite as long. Posted at 2017-11-20 by Wilberforce Are you tied to using web sockets? I have had success using the http PUT verb. The Ondata appends to the filename, and the URL of the put becomes the filename of the file you want to write too. Posted at 2017-11-21 by @gfwilliams ^^ as wilberforce says, you can pipe from normal HTTP requests really easily. That is almost certainly the best solution. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-11-18 by thebells
I have a websocket handler that writes a message to a file with the function below. However, with a large message, saving the file can take a long time. Is there a way to pipe the the websocket message directly to the file, or to speed up how long it takes to receive and save it?
Beta Was this translation helpful? Give feedback.
All reactions