Open CafaAsbl opened 7 years ago
Hi all,
I have some news, but not working fully.
In my test case, i've reverse the logic. I emit a new stream on the server and the client get it. It's working at least for ~5%, after the stream stop, without any error.
I don't understand why this is not working when i try with my first code. And i don't understand why my stream stop at 4 or 5% of transfer.
Finaly, i got no any error. All of operation seems to work normaly.
Thx for help in advance !
Server Side :
ss(socket).emit('package', stream, { size: PACKAGE_SIZE });
var read = fs.createReadStream(LAST_PACKAGE);
read.pipe(stream);
read.on('error', function(err) {
console.log('Error : ' + err);
});
read.on('data', function(chunk) {
console.log(chunk);
});
read.on('finish', function() {
console.log('Finish');
});
read.on('end', function() {
console.log('end');
});
read.on('pause', function() {
console.log('pause');
});
Client Side :
ss(socket).on('package', function(stream, data) {
var write = fs.createWriteStream(PACKAGE_FILE);
stream.pipe(write);
var size = 0;
stream.on('data', function(chunk) {
console.log('chunky chunky');
size += chunk.length;
var percent = Math.floor((size / data.size) * 100);
updateProgress(percent);
});
stream.on('end', function() {
console.info('ending');
});
stream.on('finish', function() {
console.info('Finish !');
});
stream.on('error', function(err) {
console.error('error');
});
stream.on('pause', function() {
console.log('pause');
});
});
I'm running into the same issue with a similar setup. Were you able to figure out why you're receiving an empty file? I've tried emitting the stream from both server and client side. I only have this issue between two Node.js applications, not between a browser and Node.js server.
Hi, @jhead I am facing very similar problem: everything works fine when i send file from browser to nodejs server and vice versa, but when I send file from one nodejs server to another one I get an empty file. Moreover, none of events doesn't shoot (e.g. 'data', 'end', 'finish', 'error').
So, were you able to figure this out?
Hey @OlehRb, it's been a while so I can't remember exactly but I think it ended up being an issue on my end and not with socket.io-stream. I had created some middleware for every socket event and it was interfering with the socket.io-stream events. You might try using Chrome dev tools to inspect the websocket frames to see what's going on between your client and server.
This one is old, but i just ran into this one and found out that you should set: ss.forceBase64 = true; on both sides. That solves the problem with the empty files. Took me an hour but you can read it there (https://www.npmjs.com/package/socket.io-stream): "You have to set forceBase64 option true when using the library with socket.io v0.9.x."
Hi, i got a problem with writing data.
I'm trying to upload a package from my server to my client. Event is received, but, my final file is empty. My code :
Server Side :
Client Side :
Think i miss something, but i can't see what.
Any idea ?
Thx in advance for help