Javascript: 'Self signed certificate' error during API call - javascript

I'm automating some API calls in Javascript and a few days ago this error started appearing out of nowhere.
base.js:383
1) Test API call
base.js:266
Fourth test:
FetchError: request to https://api.qa.xx.xxxx.com:443/mobile/v2/subscribers failed, reason: self signed certificate in certificate chain
at ClientRequest.<anonymous> (node_modules/node-fetch/lib/index.js:1393:11)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
I have spent countless hours trying to find a solution but nothing works. I've re-cloned the entire repo and everything. Does anybody know how to solve this?
What I did before this started happening:
Installed npm config
Installed mongodb client
I've uninstalled since

Apparently there is a related issue with two solutions,
pass an http agent, setting rejectUnauthorized
const https = require("https");
const agent = new https.Agent({
rejectUnauthorized: false
})
fetch(myUrl, { agent })
set an env var in your package.json start script
NODE_TLS_REJECT_UNAUTHORIZED="0" npm start
or use a process.env var
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

Related

HTTP 6369: SOCKET ERROR: read ECONNRESET - Node server connecting to Filemaker Data API

I have run into this error with my Node server when trying to access a Filemaker Server driven backend both locally and remotely.
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
After trying everything I can find, triple-checking my FMS settings and logs, restarting the server and the machine several times, I cannot figure out what exactly is going wrong and how to solve it.
I have seen some answers to similar questions here on SO, but for the most part they just suggest catching the error in the express route (has not been changed for months and was working fine before the error), which I have done but it just outputs a more verbose version of the main error above:
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/******/Documents/*****/code/******/node_modules/request/request.js:751:32)
THE ERR : Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
---------------------------------------------
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/********/Documents/*******/code/******/node_modules/request/request.js:751:32) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall:'read'
}
Also, my Node API in general had already been operating more or less seamlessly for several months of development before this problem arose. One thing was that changed on my machine was my company adding ScaleFusion device management software. I mentioned before the install that it could cause problems with the Node server API calls and the error only happened after ScaleFusion was added. Maybe it is possible the software is causing this problem?
Have been trying to find a fix for a couple of days now but running out of leads on it. If anyone can help out I'd really appreciate it. Thanks in advance for any suggestions.

How to fix "ENOTDIR" error when publishing to AWS Amplify

I am trying to push our latest code to our AWS Amplify project in the cloud. The other dev on our team does amplify publish and everything pushes to the cloud fine. When I do amplify publish it throws an ENOTDIR error. I feel like that means I am missing a dependency or a dependency got corrupted or something? I am at a loss.
I have tried doing amplify codegen, amplify env pull --restore, and I have tried removing and reading the #aws-amplify/cli package that I installed to my app directory with yarn when first installing everything for this web app. I know it's connected to the cloud properly because me and the other dev's amplify status output matches, as well as the amplify env get --name <environment name> command output.
The error I get every time I do amplify push is:
No changes detected
/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/gluegun/build/index.js:13
throw up;
^
Error: spawn ENOTDIR
at ChildProcess.spawn (internal/child_process.js:394:11)
at spawn (child_process.js:542:9)
at /usr/local/lib/node_modules/#aws-amplify/cli/node_modules/amplify-frontend-javascript/lib/builder.js:13:28
at new Promise (<anonymous>)
at Object.run (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/amplify-frontend-javascript/lib/builder.js:6:10)
at Object.run (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/amplify-frontend-javascript/lib/publisher.js:9:18)
at Object.publish (/usr/local/lib/node_modules/#aws-amplify/cli/node_modules/amplify-frontend-javascript/index.js:33:20)
at Command.run (/usr/local/lib/node_modules/#aws-amplify/cli/src/commands/publish.js:41:29)
at processTicksAndRejections (internal/process/task_queues.js:85:5) {
errno: 'ENOTDIR',
code: 'ENOTDIR',
syscall: 'spawn'
Thanks for any input on how to fix this! I am leery to try too much else on my own because I do not want to accidentally delete what is already in the cloud.

Error : Connect ENETUNREACH

I am fetching videos from the facebook graph api(24*7) using nodejs. My code is working fine but after every 3 or 4 days it stops working and gives the following error: (Ignore the I'm in loop statements)
Error: connect ENETUNREACH 2a03:2990:f015:12:face:b00c:0:2:443 - Local (:::0)
at Object._errnoException (util.js:1003:13)
at _exceptionWithHostPort (util.js.1024:20)
...
Check you internet connection . That solved my problem as ENETUNREACH is a network issue such as host unreachable or your gateway not working .
In my case, I just changed the localhost property to 127.0.0.1 as follows:
var connection = mysql.createConnection({
// host : 'localhost', // localhost causes somehow this error
host: '127.0.0.1',
I had a similar error, I disabled IPv6 on my computer and then the error stopped occurring.
I got the same issue. My problem was I still have the corp proxy settings in npm config. My resolution:
Check if any proxy settings in place
npm config list
Remove them
npm config delete https-proxy
You may have more. But after that, the error's gone.

Node.js HTTP GET “ECONNRESET” Error on read

I've read all the related issues on SO and GitHub about this error and none of them seem to address this situation.
When I run the following code:
response = await axios.get('http://localhost:8082/panda, {
httpAgent: new http.Agent({ keepAlive: true, keepAliveMsecs: 10000 })
});
I get the following error:
{ Error: socket hang up
at createHangUpError (_http_client.js:345:15)
at Socket.socketOnEnd (_http_client.js:437:23)
at emitNone (events.js:110:20)
at Socket.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }
{ Error: read ECONNRESET
at _errnoException (util.js:1019:11)
at TCP.onread (net.js:608:25)
code: 'ECONNRESET',
errno: 'ECONNRESET',
syscall: 'read',
etc...
There's no stack trace beyond the onread call so it's unclear how I can get any additional information beyond the ECONNRESET error code (-54) passed to the onread method in net.js
This issue happens with every request - it is not intermittent.
A few observations:
when making the same request from chrome or postman the request does NOT fail
attempting to reproduce a successful request from Chrome, by using the same headers, fails
setting the accept header to use 'gzip', etc.. does not help - I have tried all the recommendations including some weird ones like setting the content length and adding a body to the request despite this being a GET request
the error always appears in net.js, but happens with both the request and axios libraries
Here's the interesting part - I can only seem to reproduce this problem reliably when I am hosting the server locally. I am able to reach the dev instance or run the server in vagrant, via a docker container, without issue.
I am running macOS Sierra 10.12.6 if that makes any difference. The server is written in Java and uses the Spring framework. Here is the RestTemplate configuration I'm using for HTTP calls:
#Bean
public RestTemplate restTemplate() {
//request timeout
int timeout = 5000;
//Connection Pooling factory with timeouts to prevent disastrous request responses
HttpComponentsClientHttpRequestFactory cf = new HttpComponentsClientHttpRequestFactory();
cf.setReadTimeout(timeout);
cf.setConnectTimeout(timeout);
cf.setConnectionRequestTimeout(timeout);
return new RestTemplate(cf);
}
I've tried messing around with these settings with no luck.
Any ideas?
I have the same issue. The cause was in my proxy settings. I make proxy-port localhost:8080 to my localhost:3000. That's why all API requests from my NodeJS app to localhost:3000 returned "ECONNRESET" Error. When I delete proxy-port, the issue was resolved. Check your net settings. Maybe it's redirecting problem
This was a known issue with NodeJS and has been resolved. Please see http.Agent: idle sockets throw unhandled ECONNRESET for details.
Also ensure you have enabled the correct security settings when opening a port on MacOS

Mongod not functioning correctly

I keep getting this response when trying to run a node app with a MongoDB
body-parser deprecated bodyParser: use individual json/urlencoded middlewares server.js:32:9
body-parser deprecated undefined extended: provide extended option node_modules/body-parser/index.js:105:29
express-session deprecated undefined resave option; provide resave option server.js:35:9
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option server.js:35:9
Running on3000
/Users/tvc/Desktop/SupperClubApp/node_modules/mongoose/node_modules/mongodb/lib/server.js:228
process.nextTick(function() { throw err; })
^`
Error: connect ECONNREFUSED
at exports._errnoException (util.js:746:11)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1010:19)
I am unsure as to how to resolve it. Any tips much appreciated.
Analysis:
the issue as per the exception that you copied in the comments says that you Mongodb connection could not be established as there was an issue with Mongodb connection close the previous time. Mongodb will encounter this issue when your computer was forceshutdown due to power outages and other issues.
the exception content from your comments is as below:
[initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty. 2015-10-06T09:50:54.164+0100 D - [initandlisten] User Assertion: 98:Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?
Investigation:
Check if there is a file named Mongod.lock got created in your \bin folder.
Solution:
If the size of the file Mongod.lock is greater than 0KB, please delete the file and re run your mongodb. It should work fine. More details at this link

Categories

Resources