Repository navigation
Problem with pipe : EPIPE read. #10415
Copy link
Copy link
Closed
Labels
netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.questionIssues asking questions about Node.js.Issues asking questions about Node.js.
Description
I'm trying to make a pipe request to Dropbox application on window (not the Dropbox API)
But i'm getting
{ [Error: read EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'read' }
Could anyone look into this code an tell what might be wrong?
var net = require('net');
var ffi = require('ffi');
var ref = require('ref');
var BufferStream = require('node-bufferstream')
var PIPE_PATH = "\\\\.\\pipe\\DropboxPipe_1"
var UserName = "YourUserName"
var L = console.log;
var struct = require('python-struct');
var SessionId = ref.alloc("uint");
var encoding = require("encoding");
var kernel32 = new ffi.Library("kernel32",{
GetLastError:['string',[]],
GetCurrentProcessId: ['int',[]] ,
GetCurrentThreadId: ['int',[]],
ProcessIdToSessionId: ['bool',['int','uint *']],
CallNamedPipeA:['bool',[]]
});
var RequestInfo = 0x3048302;
var ProcessId = kernel32.GetCurrentProcessId();
var ThreadId = kernel32.GetCurrentThreadId();
var RequestType =1;
var dropbox = ref.types.void;
if(!kernel32.ProcessIdToSessionId(ProcessId,SessionId )){
console.log(kernel32.GetLastError());
}
else{
//console.log(SessionId);
SessionId.type = ref.types.int;
SessionIdInt = SessionId.deref();
console.log(SessionIdInt);
}
var mypath = "C:/Users/"+UserName+"/Dropbox/"
var L = console.log;
var client = net.createConnection({ path: '\\\\.\\pipe\\DropboxPipe_1'}, function () {
console.log('connected');
var wtf = 0x3048302;
var request = struct.pack("LLLL",wtf,ProcessId, ThreadId,RequestType) + encoding.convert(mypath,"utf-16le")
var str = new Array(540 + 1).join( String.fromCharCode(0) );
request = request + str;
var request = request.substr(0,540);
client.write(request, ()=>{
console.log("write callback"); //this part is written to console
console.log(client.bytesWritten) // 550
console.log(client.bytesRead) //0
});
});
client.on("error", function(e) { console.log(e); });
client.on('data', function(data) {
L('Client: on data:', data.toString());
client.end('Thanks!');
});
client.on('end', function() {
L('Client: on end');
})
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
netIssues and PRs related to the net subsystem.Issues and PRs related to the net subsystem.questionIssues asking questions about Node.js.Issues asking questions about Node.js.
Activity
mscdex commentedon Dec 22, 2016
This is probably best asked on the nodejs/help repo unless it can be verified that there is a bug in node.
Fishrock123 commentedon Dec 22, 2016
tl;dr: you're piping to a closed stream/file descriptor somewhere, perhaps something is closing it prematurely?