使用node-ipc连接节点进程会产生错误:connect EACCES

时间:2019-10-04 20:21:58

标签: javascript node.js ipc node-ipc

我有两个节点应用程序,一个在名为:“ provider”的debian服务器帐户上。在提供程序上,我的节点应用程序中运行着ipc服务器,该服务器具有以下配置:

var ipc = require('node-ipc');
ipc.config.id   = 'remote_provider';
ipc.config.retry= 1500;
ipc.config.sync = true;

ipc.serve(
    function(){
        ipc.server.on(
            'grab',
            async  function(data,socket){

                  var result;
                  //some computation and stuff not related to question
                  ipc.server.emit(
                       socket,
                       'result',
                       result
                  );


            }
        );
        ipc.server.on(
            'socket.disconnected',
            function(socket, destroyedSocketID) {
                ipc.log('client ' + destroyedSocketID + ' has disconnected!');
            }
        );
    }
);

ipc.server.start();

我也有一个帐户“观察者”的客户端nodejs流星应用程序。 此应用程序按需将客户端提供给“提供者” ip服务器,然后获取一些数据。

客户端ipc如下所示:

var ipc=require('node-ipc');

ipc.config.id = 'observer_request_' + user_id;
ipc.config.retry = 1000;
ipc.config.maxRetries = 0;
ipc.config.sync = true;

ipc.connectTo('remote_provider');

ipc.of.remote_provider.on(
'disconnect',
function () {
      ipc.log('disconnected'.notice);
    }


);
ipc.of.remote_provider.on(
'error',
function (err) {
     ipc.log(err);

    }
);
ipc.of.remote_provider.on(
'result',
function (data) {
      console.log(data);
    }
);


ipc.of.remote_provider.emit(
   'grab',
    id
);


On localhost i tested this setup on the same account, works good. But on server, when i uploaded to different accounts, get this error on client, when trying to connect:

 connect EACCES /tmp/app.data_provider

有人可以帮助将客户端连接到其他用户帐户上的ipc服务器吗?

0 个答案:

没有答案