Skip to content

Problem with pipe : EPIPE read. #10415

Closed
Closed

Description

@ambrt

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');
})

Activity

  1. mscdex commented on Dec 22, 2016

    @mscdex
    Contributor

    This is probably best asked on the nodejs/help repo unless it can be verified that there is a bug in node.

  2. added
    netIssues and PRs related to the net subsystem.
    on Dec 22, 2016
  3. Fishrock123 commented on Dec 22, 2016

    @Fishrock123
    Contributor

    { [Error: read EPIPE] code: 'EPIPE', errno: 'EPIPE', syscall: 'read' }

    Could anyone look into this code an tell what might be wrong?

    tl;dr: you're piping to a closed stream/file descriptor somewhere, perhaps something is closing it prematurely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    netIssues and PRs related to the net subsystem.questionIssues asking questions about Node.js.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions