Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:从nodejs运行python子进程时读取ECONNRESET_Python_Node.js_Amazon Ec2 - Fatal编程技术网

错误:从nodejs运行python子进程时读取ECONNRESET

错误:从nodejs运行python子进程时读取ECONNRESET,python,node.js,amazon-ec2,Python,Node.js,Amazon Ec2,我从NodeJS在EC2 Ubuntu上运行python子进程时出错。node.js永远不会调用派生的子进程,但是在本地服务器上工作得非常好。 我们最初得到一个EPIPE错误,直到我们使用“sudo apt get install libfontconfig”,然后产生以下错误: events.js:160 throw er; // Unhandled 'error' event ^ //error Error: read ECONNRESET at export

我从NodeJS在EC2 Ubuntu上运行python子进程时出错。node.js永远不会调用派生的子进程,但是在本地服务器上工作得非常好。 我们最初得到一个EPIPE错误,直到我们使用“sudo apt get install libfontconfig”,然后产生以下错误:

events.js:160
      throw er; // Unhandled 'error' event
      ^ //error Error: read ECONNRESET
    at exports._errnoException (util.js:1020:11)
    at Pipe.onread (net.js:568:26)



        //child process             
        urlCrawlJob(hostname, pageCounter+1, accessToken); //recursive calling of the function


        var process = SPAWN('python', [PATH.join(__dirname,"../pyScripts/crawler.py")]),

        data = body.customers;
        dataString = '';

        console.log(`Spawned child pid: ${process.pid}`);
        process.stdout.on('error', function (err) {
            console.log('stdout error: ', err);
            console.log(err.code);
        });

        process.stdout.on('data', function(data){
            dataString+=data
            console.log(dataString);
        });
        process.stdout.on('end', function(){

            console.log("ending child process -----> call url");

        });
        process.stdin.write(JSON.stringify({"data":data,"hostname":hostname}));
        process.stdin.end();                

    //python script

## process_init.py

#crete seperate function, impletment oop concepet

import sys, json, pymongo, os


#defaukt address, email, phnNo, total spe

print "==> in crawler python"

#print sys.args[0];

def main():
    data = json.load(sys.stdin)
    hostname = data['hostname'];
    customerData = data['data'];

    print hostname


    collection = dbConnection(hostname)


    #isFile = open("/crawlerResult/"+hostname+".txt","w+")


    pwd = os.getcwd()

    print pwd
    file = open(pwd+"/crawlerResult/"+hostname+".txt", "a++")

    iteratingData(customerData, file, collection)


    print "=====\n\n"
    client.close();                             #close the db connection
    sys.stdout.flush();  

def dbConnection(hostname):

    #opening connection with db
    client = pymongo.MongoClient('127.0.0.1', 27017) ;                          # TODO: if connection already open do not open neew one
    #   print client
    db = client["customerLTV"];
    print db
    collection = db[hostname];
    return collection


def iteratingData(customerData, file, collection):

    count = 0
    data = {}
    for i in customerData:
        #print i
        count += 1
        #print len(i["addresses"]);

        try:


            strdata = {}
            strdata[count] = data   
            strdata = json.dumps(strdata)
            file.write(strdata + "\n")                  


            data.pop('_id', None)
            collection.insert(data)         
            data = {}
        except Exception, e:
            print str(e)

    print count;




#start process
if __name__ == '__main__':
    main()

看起来你的模块没有正确安装在Ubuntu服务器上。您是否安装或更新了所有Ubuntu EC2模块?尤其是在Python子进程未运行的情况下。

嘿,谢谢,我正在考虑您的解决方案,我认为这是正确的,因为模块不存在。。。你救了我一天。