I am not sure if this is a bug or not.
According to websocket/ws documentation you can use NodeJS streams.
However, my browser only receives Binary messages when doing this, despite setting encoding to utf8
:
(new WebSocket.Server({port: 8080})).on('connection', function(ws){
var duplex = WebSocket.createWebSocketStream(ws, {encoding: 'utf8'});
var stream = require('fs').createReadStream(pathToFile, {encoding: 'utf8'});
stream.pipe(duplex);
});
Is this a bug, or how can I stream it as utf8
?