Nodejs request problem - Error: write EPROTO - node.js

node: v10.19.0
request: v2.88.2
jsdom: v11.12.0
When I use my Nodejs app in my city home with optical fibre, everything is ok, but, when I use my Nodejs app at my summer house where I use mobile internet (T-mobile), I get this error (probably because of the different operator) when attempting to access some pages.
Error: write EPROTO 140216527574848:error:1414D172:SSL
routines:tls12_check_peer_sigalg:wrong signature
type:../ssl/t1_lib.c:1145:
Honestly, I have no idea what is going on. The only similar topic I have found is this:
cloud9 nodejs - Error: write EPROTO 140261073610560. and in localhost everything ok
var requestData = request(url, function(err, resp, HTMLdata) {
if (!err && resp.statusCode === 200) {
console.log('Request success \n');
}
});
I have a router from T-mobile (Huawei which does not have a bridge option).
So, if this is a port problem I can access the router, but, what should I change?

Related

timeout error handling with node.js and express

In my app using node.js and Express I've got a problem with handling timeout error during my request to some 3rd party shop's url. Sometimes shop's server is overloaded and I get a timeout error.
That's my code:
request(url, function (error, response, html) {
console.log("response.statusCode: " + response.statusCode);
if (!error && response.statusCode == 200) {
console.log("OK");
//some code
}
});
I managed to handle errors like 404 but I don't know how to handle timeout connection error. I've read about connect-timeout module for node.js, but I think it is more for for 'in app' requests, rather than for request to 3rd party url. Do I think correctly? What does time after which I get timeout error depends on?

rally node sdk giving back Error: getaddrinfo ENOTFOUND

I keep getting the following error response from node when trying to run a read call to rally:
Error: getaddrinfo ENOTFOUND rally1.rallydev.com rally1.rallydev.com:443
I am using the Rally Node SDK, and node v7. I am on a local machine. It is successfully reaching and logging the 'releaseoid' before the 'try'.
I feel like I am not specifying http (which I was before and now completely commented out the server, letting the SDK default it). But it is continuing to give back that error. I could not find (or possibly understand) other general Node guidance that may address this situation. I am not clear where port 443 is coming from as I am not specifying it. Is the SDK adding it?
If I specify the server address without http:
server: 'rally1.rallydev.com',
I still get an error, but this time:
Error: Invalid URI "rally1.rallydev.com/slm/webservice/v2.0null
I am new to Node and not sure if I am having a problem with Node or the Rally Node SDK.
Code below.
var rally = require('rally');
var rallyApi = rally({
apiKey: 'xx',
apiVersion: 'v2.0',
//server: 'rally1.rallydev.com',
requestOptions: {
headers: {
'X-RallyIntegrationName' : 'Gather release information after webhook',
'X-RallyIntegrationVendor' : 'XX',
'X-RallyIntegrationVersion' : '0.9'
}
}
});
// exports.getReleaseDetails = function(releaseoid, result) {
// console.log('get release details being successfully called');
//
//
//
// }
module.exports = {
getReleaseDetails: async(releaseoid) => {
console.log(releaseoid);
try {
let res = await
rallyApi.get({
ref: 'release/' + releaseoid,
fetch: [
'Name',
'Notes',
'Release Date'
]
//requestOptions: {}
});
res = await res;
console.log(res);
} catch(e) {
console.error('something went wrong');
console.log(e);
}
}
}
That mostly looks right. I haven't tried to use async/await with the node toolkit yet- it would be interesting to see if that works. It should, since get and all the other methods return promises in addition to handling standard node callback syntax.
But anyway, I think the issue you're having is a missing leading / on your ref.
rallyApi.get({
ref: '/release/' + releaseOid
});
Give that a shot?
As for the network errors, is it possible that you're behind a proxy on your network? You're right though, https://rally1.rallydev.com is the default server so you shouldn't have to specify it. FYI, 443 is just the default port for https traffic.

node request module - sample request failing

I'm currently using node 7.6.0 and am trying the npm request module 2.80.0. The module is installed via package.json npm install. Following their simple example I immediately get: "Failed: Cannot set property 'domain' of undefined". Its a straight copy paste except for the require part.
var request = require('../node_modules/request/request');
request('http://www.google.com', function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});
Am I missing something or is there other dependencies I'm not aware of?
I required it incorrectly. Should just be node_modules/request. Confusing since there is an actual request.js inside the request folder with a module exports.
// Exports
Request.prototype.toJSON = requestToJSON
module.exports = Request

NODE JS http form post failing without fidler proxy

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.

SSL Error in nodejs

I'm trying to get a webpage via node https.request(). Doing so results in an error getting logged by my code. Using the node request module has the same result:
problem with request: 140398870042432:error:140773F2:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message:s23_clnt.c:658:
The following indicates the wrong SSL version is being used, but I cannot find a way to change the version: curl error: "sslv3 alert unexpected message". Using curl from my terminal returns a response as does hitting the URL in my browser (it is a login page). My code is below.
var request = require('request')
request.get("https://icmserver.wit.ie/balance", function(err, res, body) {
if (err) {
return console.log(err)
}
return body;
});
Does anyone have any idea what might be happening here?
Try to use options = { secureProtocol: 'SSLv3_method' } in the request you are making.
We hit the same problem. By default, request uses the https.globalAgent. So we added the code near the top of our script.
var https = require('https');
https.globalAgent.options.secureProtocol = 'SSLv3_method';
All of a sudden everything worked.
In case website uses ECDH curve, for me the issue resolved only by adding this option:
request({ url, agentOptions: {
ecdhCurve: 'P-521:P-384:P-256',
},(err,res,body) => {
JFYI, May be this will help someone.

Resources