I am making http form post using request node module (https://www.npmjs.org/package/request).
The post request fails with error - {"code":"ECONNRESET","errno":"ECONNRESET","syscall":"read","level":"error","message":"","timestamp":"2014-09-05T17:35:34.616Z"}
If I run fiddler and channel the request via fiddler, it works fine.
Any idea why would that happen and how I can resolve it!
Here is the exact code I am using. It works as long as I use it as stand alone node js. But, if its made a web app, it fails. It seems to work a few times.., but fails continuously after that. At this point, even the stand alone node js fails to run.
However, when I enable the proxy and open fiddler, it works magically!
var request = require('request');
var url = "https://idctestdemo.hostedcc.com/callcenter/mason/agents/pipes/muterecording.pipe"//"https://restmirror.appspot.com/"
,form_data = {"pipe-name": "Deepak"};
var args = { url: url, form: form_data};
if(process.argv.length > 2){
var enable_proxy = process.argv[2];
if(enable_proxy && enable_proxy[0] == 'p'){
console.log('enabling proxy')
args['proxy'] = 'http://127.0.0.1:8888';
args["rejectUnauthorized"] = false;
}
}
var oclient = request.post(args
,function(error, response, body){
if (error){
console.log('error in reponse');
console.error(error);
} else {
console.log('success!');
console.dir(body);
}
});
oclient.on('error',function(err){
console.log('client error');
console.error(err);
});
oclient.on('end',function(end_data){console.log('end', end_data)});
oclient.on('data',function(d){console.log('on data', d)});
console.log('waiting for response...')
If everything goes well, the expected response should be
<script>
parent.xb.pipe.onNotify('Deepak',{desc:'Pipe opened by server',payload:{time:'Mon Sep 8 12:58:18 2014'},type:'MSG_OPENED'});
</script>
<script>
parent.xb.pipe.onNotify('Deepak',{desc:'Not logged in',payload:{hostcode:'ny-1'},type:'ERR_NOLOGIN'});
</script>
<script>
parent.xb.pipe.onNotify('Deepak',{desc:'Pipe closed by server',payload:null,type:'MSG_CLOSED'});
</script>
ECONNRESET
means the other side you want to connect/send data to, is not accepting requests. Maybe you can find more information by looking into the server log.
You also could try to check what happens if you change the port listen to.
If I should help more, I need more information.