{"action":"opened","issue":{"url":"https://api.github.com/repos/nkzawa/socket.io-stream/issues/96","repository_url":"https://api.github.com/repos/nkzawa/socket.io-stream","labels_url":"https://api.github.com/repos/nkzawa/socket.io-stream/issues/96/labels{/name}","comments_url":"https://api.github.com/repos/nkzawa/socket.io-stream/issues/96/comments","events_url":"https://api.github.com/repos/nkzawa/socket.io-stream/issues/96/events","html_url":"https://github.com/nkzawa/socket.io-stream/issues/96","id":193483913,"number":96,"title":"Stream.pipe event 'end' triggers only once","user":{"login":"dmarman","id":19510612,"avatar_url":"https://avatars.githubusercontent.com/u/19510612?v=3","gravatar_id":"","url":"https://api.github.com/users/dmarman","html_url":"https://github.com/dmarman","followers_url":"https://api.github.com/users/dmarman/followers","following_url":"https://api.github.com/users/dmarman/following{/other_user}","gists_url":"https://api.github.com/users/dmarman/gists{/gist_id}","starred_url":"https://api.github.com/users/dmarman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmarman/subscriptions","organizations_url":"https://api.github.com/users/dmarman/orgs","repos_url":"https://api.github.com/users/dmarman/repos","events_url":"https://api.github.com/users/dmarman/events{/privacy}","received_events_url":"https://api.github.com/users/dmarman/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-05T12:26:16Z","updated_at":"2016-12-05T12:26:16Z","closed_at":null,"body":"I have a server and a client set up with nodejs. The server is sending a file to the client with socket.io-stream. When the file is transfered I want to start working with it on the client side. For that I am listening to the 'end' event of the stream. My code works but only once. On the first file I send the event is triggered, but not on the next ones. After the first file, the next ones are corrupted and are 0 Bytes.\r\n\r\nserver.js\r\n\r\n```\r\n socketObj.emit('order', orderData);\r\n\r\n ss(socketObj).on('file', function(stream) {\r\n            fs.createReadStream('./uploads/'+ orderData.file.name +'').pipe(stream);\r\n });\r\n```\r\n\r\nclient.js\r\n\r\n```\r\nsocket.on('order', function(data) {\r\n\r\n    var stream = ss.createStream();\r\n\r\n    ss(socket).emit('file', stream);\r\n\r\n    stream.pipe(fs.createWriteStream(data.file.name));\r\n\r\n    stream.on('end', function(){\r\n        doSomeStuff(data); //This function is called only once\r\n    });\r\n\r\n});\r\n```\r\n\r\nI've tried using 'end' and 'finish' events, setting autoClose as true and false, using stream.close() and stream.end(), but nothing works. For me is like something is not resetting properly.\r\n"}}
{"actor":{"display_login":"dmarman"}}