Answer the question
In order to leave comments, you need to log in
NodeJS+DNode+Php - error Error: write EPIPE?
Good day.
Once again I struggle with incomprehensible moments for me in nodeJs. Now I've encountered an error that again I can't solve on my own and I'm asking for the community's help:
I'm writing a PHP application and decided to transfer some functionality to NodeJS in view of its performance, flexibility and easy scalability.
So what is:
- RPC Server on NodeJS. Communication with PHP is organized through the DNode module which exists for both languages. But PHP while I plan to use as the client.
So NodeJS side:
require('epipebomb')()
require('./includes/array.js')
var dnode = require('dnode')
var net = require('net')
var request = require('request')
var tidy = require('tidy2')
var util = require('util')
var dom = require('xmldom').DOMParser
var server = net.createServer(function (c) {
var d = dnode({
mul: function (requestUrl,fields,callback){
request(requestUrl, function (error, response, body) {
console.log('Fetch url:'+requestUrl);
if (!error && response.statusCode == 200) {
var html=tidy.tidyString(body)
var doc = new dom().parseFromString(html)
for ( var key in fields ) {
var subfields = fields[key]
for(var subkey in subfields){
console.log(subfields[subkey])
//Include extensions for processing
require('./includes/'+subfields[subkey]+'.include.js')
global[subfields[subkey]](subkey,doc,requestUrl);
}
//Dummy
var array
callback(array);
}
}
})
}
})
c.pipe(d).pipe(c);
});
server.listen(5050)
public function run($args){
require_once "extensions/DNode/DNode.php";
$dnode = new \DnodeSyncClient\Dnode();
$connection = $dnode->connect('localhost', 5050);
$fields=Fields::model()->findAll();
foreach($fields as $field){
$js_field[$field->name]=array($field->path=>$field->function);
}
$pages=Pages::model()->findAll();
foreach($pages as $page){
$response = $connection->call('mul', array($page->url,$js_field));
var_dump($response);
}
}
stream.js:81
throw er; // Unhandled stream error in pipe.
^
Error: write EPIPE
at errnoException (net.js:769:11)
at Object.afterWrite (net.js:593:19)
Answer the question
In order to leave comments, you need to log in
github.com/mhart/epipebomb#notes
epipebomb catches only those errors that are caused by console EPIPEs
In general, this is most likely a bug in the dnode itself, for some reason it tries to write to a socket that can no longer be written to. There even already is a bug on this topic: github.com/substack/dnode/issues/107
I recently fixed these errors in axon'e .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question