axios: Error: Client network socket disconnected before secure TLS connection was established - node.js

I'm trying issue a post to a soap web service at following url https://xxx.xxx.gov.ar/AntecedentesService/AntecedentesService.asmx and I get the following error:
Error: Client network socket disconnected before secure TLS connection was established
at TLSSocket.onConnectEnd (_tls_wrap.js:1088:19)
at Object.onceWrapper (events.js:277:13)
at TLSSocket.emit (events.js:194:15)
at endReadableNT (_stream_readable.js:1125:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
code: 'ECONNRESET',
path: null,
host: 'xxx.xxx.gov.ar',
port: 443,
If I issue a post with curl like this:
curl -X POST -H "Content-Type: text/xml" -d #request01.xml https://xxx.xxx.gov.ar/AntecedentesService/AntecedentesService.asmx
it works ok. If I try to access it from vscode using the rest client plugin I get exaclty the same error, so I guess it could be a problem with node.
Just to dismiss axios, I also tried with https.request following this example, and I get the same error
Any idea how to solve it?
I'm using node v10.15.3 and axios 0.18.0 from Linux pop-os 4.15.0-48-generic

Related

Decentraland project not starting properly

I am trying to run 'dcl start' command from the terminal. The Decentraland Preview webpage opens and terminal says 'Acquring comms connection'. But after that it gives the error below:
Oops, it seems the catalyst isn't working well. [HPM] Error occurred while proxying request 127.0.0.1:8000/lambdas/collections/wearables?collectionId=urn:decentraland:off-chain:base-avatars to https://peer.decentraland.org/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors) Oops, it seems the catalyst isn't working well. [HPM] Error occurred while proxying request 127.0.0.1:8000/lambdas/collections/wearables?wearableId=urn:decentraland:off-chain:base-avatars:elegant_striped_shirt&wearableId=urn:decentraland:off-chain:base-avatars:elegant_blue_trousers&wearableId=urn:decentraland:off-chain:base-avatars:f_m_sandals&wearableId=urn:decentraland:off-chain:base-avatars:modern_hair&wearableId=urn:decentraland:off-chain:base-avatars:f_mouth_04 to https://peer.decentraland.org/ [ECONNRESET] (https://nodejs.org/api/errors.html#errors_common_system_errors) [HPM] ECONNRESET: Error: socket hang up at connResetException (node:internal/errors:704:14) at TLSSocket.socketOnEnd (node:_http_client:505:23) at TLSSocket.emit (node:events:525:35) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { code: 'ECONNRESET' }
What could cause this error ?

Vercel Serverless function with nuxtjs ECONNRESET Client network socket disconnected before secure TLS connection was established

so i'm having this problem on a nuxt implementation with vercel, at random moments the site doesn't load and throws a 502 http error
this is the stacktrace of vercel:
ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"FetchError: request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","reason":{"errorType":"FetchError","errorMessage":"request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","code":"ECONNRESET","message":"request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established","type":"system","errno":"ECONNRESET","stack":["FetchError: request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established"," at ClientRequest.<anonymous> (server.js:16011:11)"," at ClientRequest.emit (events.js:315:20)"," at ClientRequest.EventEmitter.emit (domain.js:483:12)"," at TLSSocket.socketErrorListener (_http_client.js:426:9)"," at TLSSocket.emit (events.js:315:20)"," at TLSSocket.EventEmitter.emit (domain.js:483:12)"," at emitErrorNT (internal/streams/destroy.js:92:8)"," at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)"," at processTicksAndRejections (internal/process/task_queues.js:84:21)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: FetchError: request to {api_url} failed, reason: Client network socket disconnected before secure TLS connection was established"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:327:22)"," at process.EventEmitter.emit (domain.js:483:12)"," at processEmit [as emit] (/var/task/node_modules/signal-exit/index.js:161:32)"," at processPromiseRejections (internal/process/promises.js:209:33)"," at processTicksAndRejections (internal/process/task_queues.js:98:32)"]}
Unknown application error occurred
So the error it's about a connection with the api, for what i found this is a Node error but my api is developed on Laravel so i'm really lost
Thanks for the help
I ran into this issue (with a Next.js project on Vercel) and fixed it. I was calling an external API but forgot to await one of the handlers, so the Lambda eventually stopped waiting for the API call response once my code finished running.

NodeJs EHOSTUNREACH in Express

I am facing problem on server while calling external API on HTTPS. I am checking with HTTPS. On Local its working fine without any issue
Here is my error
Error: connect EHOSTUNREACH 54.147.133.143:443
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
errno: 'EHOSTUNREACH',
code: 'EHOSTUNREACH',
syscall: 'connect',
address: '54.147.133.143',
port: 443
}
if i hit the curl request on server directly and its working fine.
curl -H "Authorization: Bearer mytoken"
https://api.example.com/v3/a/accountid/companies.json
Any idea what could be the issue

How to use TLSv1.3 with nodejs 10.x

I was trying to make an external api call using https and got the following error.
Error: Client network socket disconnected before secure TLS connection was established
at TLSSocket.onConnectEnd (_tls_wrap.js:1092:19)
at Object.onceWrapper (events.js:286:20)
at TLSSocket.emit (events.js:203:15)
at endReadableNT (_stream_readable.js:1129:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
code: 'ECONNRESET',
On further investigation I came to know that my api endpoint uses TLSv1.3 and since I am using nodejs 10.x, I need to set
tls.DEFAULT_MAX_VERSION = 'TLSv1.3';
after which it is throwing the following error
TypeError [ERR_TLS_INVALID_PROTOCOL_VERSION]: "TLSv1.3" is not a valid maximum TLS protocol version
at toV (_tls_common.js:49:9)
at new SecureContext (_tls_common.js:74:23)
at Object.createSecureContext (_tls_common.js:100:13)
at Object.connect (_tls_wrap.js:1127:48)
at Agent.createConnection (https.js:120:22)
at Agent.createSocket (_http_agent.js:227:26)
at Agent.addRequest (_http_agent.js:185:10)
at new ClientRequest (_http_client.js:249:16)
at request (https.js:289:10)
at Object.get (https.js:293:15)

Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT

I have a sails app. I am running the app in AWS. When i run the code in development mode(sails lift --verbose) it works fine. I am able to access it from the browser bye typing the Ip and port no.(xx.xx.xxx.xx:1337/). But when i run the code in production mode (sails lift --prod --verbose) i am not able to access by ip(xx.xx.xxx.xx) when i try with xx.xx.xxx.xx:1337 it gives me the below error.
Grunt :: Done, without errors.
Unable to parse HTTP body- error occurred:
Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT
at RedisClient.flush_and_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect- redis/node_modules/redis/index.js:142:13)
at RedisClient.on_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:180:10)
at Socket.<anonymous> (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:95:14)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickDomainCallback (node.js:492:13) [Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT]
Unable to parse HTTP body- error occurred:
Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT
at RedisClient.flush_and_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:142:13)
at RedisClient.on_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:180:10)
at Socket.<anonymous> (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:95:14)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickDomainCallback (node.js:492:13) [Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT]
please suggest a possible solution.
Check if you are hardcoding the host in session.js with ip, change it to localhost.
For your question on how to access without port 1337, You need to set up a reverse proxy, say NginX, open up just the port 80 for public access, configure nginx to route the request coming to port 80 to your sails app running on port 1337, use something like pm2 or forever to run the sails app.
Steps to setup NginX as reverse proxy is explained here: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04

Resources