Problem with POST call using HTTP Request node (read ECONNRESET - rejected)

Hello everyone,

After updating to n8n v1.4.1 I have a problem during a POST call to a Microsoft Teams webhook using the Http Request node which returns the error:

ERROR:

ERROR: The connection to the server closed unexpectedly, perhaps it is offline. You can retry request immediately or wait and retry later.
read ECONNRESET

CAUSE:

{"status":"rejected","reason":{"message":"read ECONNRESET","name":"Error","stack":"Error: read ECONNRESET\n    at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)","code":"ECONNRESET"}}

STACK:

NodeApiError: The connection to the server wes closed unexpectedly, perhaps it is offline. You can retry request immidiately or wait and retry later.
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1281:27)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:631:53

NODE:

The post with n8n version 0.241 worked fine.
The problem seems to be that the proxy (zscaler) set in the system vars causes the call to fail.
In my case I am making a post call to an https address (https://XXXXXX.webhook.office.com/webhookb2/XXXXXXX-XXXX-XXXX) while the proxy is in http

Trying with CURL inside the docker container where n8n is installed the call works fine.

I still tried to run a nodejs script where I simulated the web call using the REQUEST module and its work, but if I use the AXIOS module I get the [ERR_FR_TOO_MANY_REDIRECTS]: Maximum number of redirects exceeded .
I attach nodejs script with axios:

const axios = require('axios');
let data = JSON.stringify({
  "type": "message",
  "attachments": [
    {
      "contentType": "application/vnd.microsoft.card.adaptive",
      "summary": "service status",
      "content": {}
    }
  ]
});

let config = {
  method: 'post',
  maxBodyLength: Infinity,
  url: 'https://xxx.webhook.office.com/webhookb2/2xxxxxxbf/IncomingWebhook/xxxxxxxxx',
  headers: { 
    'Content-Type': 'application/json'
  },
  data : data
};

axios.request(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});



Can anyone help me?
Thank you

Information on n8n setup

  • n8n version: 1.4.1
  • Database: postgresql
  • Running n8n via DOCKER
  • Operating system: LINUX UBUNTU

Hi @cescog :wave: Welcome to the community :tada:

That sounds like a protocol or network issue. Is there anything server side that may have changed? A user here realised it was an issue with not having a static IP:

There’s also a couple of solutions here:

Hi @EmeraldHerald

no changes on the server and network side, the problem appeared when i updated the version to v1.4.0 from v0.230.
From various tests it seems that the problem is that I perform an HTTPS POST call while the proxy is HTTP, if you look at the example with AXIOS written above, I managed to make it work by setting proxy = false and https agent:

let config = {
   method: 'post',
   maxBodyLength: Infinity,
   url: uri,
   headers: {
     'Content-Type': 'application/json'
   },
   date : date,
   proxy:false,
   httpsAgent: new HttpsProxyAgent.HttpsProxyAgent('http://***.zscaler.net:***')
};

An important thing to point out is that both in version 0.241 and currently I set the variable N8N_USE_DEPRECATED_REQUEST_LIB = true
but now it is deprecated, as reported here (n8n v1.0 migration guide | n8n Docs -data-retention) has been removed and deprecated. Could this be relevant?

1 Like

Ah, thanks for going into a little bit more detail here :bowing_man:

I checked in with @Jon just to be sure - there are some issues when using proxies with n8n which we will be looking to resolve soon. The issue itself comes from the Axios package we use not supporting https over http. If your proxy supports it you can set up https and that will work, but depending on what your proxy is used for (content inspection) it may cause other issues.

I’ll make sure to mention this thread in our internal ticket for the topic, too. :bowing_man:

2 Likes

We have already asked the company IT for the possibility of having the proxy in HTTPS but currently it is not available. :roll_eyes:
I’ll then wait for the release or other communications. :+1:

Thanks again

1 Like

Hi @EmeraldHerald,

Same issue for me. We use http proxy and since the update some requests made through HTTP Request node fall in error. Before the update I used the env variable N8N_USE_DEPRECATED_REQUEST_LIB to be able to make my requests work but since it’s deprecated it’s not possible anymore.

Unfortunatly we can’t update our n8n instance (and use last features) while http request node not accept http proxy for https requests.

I was wondering if you plan to correct this ?

Thank in advance for your reply.

Hey @Kent1,

We are planning to fix it but there isn’t a quick solution as the issue is with the package we use to make all of our HTTP calls so this would impact every node.

2 Likes

I understand.

Let me know when the fix will be released, I could be one of our beta tester :slight_smile: .

Thank for your reply.

1 Like

Just a quick question, do you know if axios supports https over http proxy in latest version ? If yes, maybe I can try to update the axios version in my env to check if it’s work ?

Hey @Kent1,

Axios still doesn’t support it there are a few bugs open around it with no movement on it. I was going to dig into this more today but got caught up with some issues. This is one of those issues that is fairly high up on my personal list of things that I want to fix so it will happen :slight_smile:

Thank @Jon for your help.

For info, the package proxy-agent I’m able to make https request through my http corporate proxy. You can see this workflow bellow :

I don’t know if it could help you but just in case :slight_smile:

1 Like

Hey @Kent1,

proxy-agent was one of the packages on my list to look at, We need to do some checks before adding new packages :slight_smile:

2 Likes

Hello,

It works also with https-proxy-agent package that is already present as package in the version 1.11.1 of n8n

1 Like

That is the one I am thinking about.

1 Like

I updated the file NodeExecuteFunctions.js in the docker image and it works great now, in waiting the official correction.

1 Like

That is probably the right place, It would just need to be tested in the the different possible combinations to make sure it doesn’t break anything which is where the hard work comes into it.

1 Like

Of course I understand that it’s not easy to just add few lines if codes. It can cause other problems. As I said for now my quick and dirty fix do the job but I wait with impatience the official fix :wink:

1 Like

Hi,

Just to know if there is an official update on this problem ? For the moment each time I update n8n version I update few lines of code in Dockerfile but if there is an official solution I’m taking it :wink:.

If necessary I could show you what I do to bypass the problem with http proxy.

Anyway I love what you do n8n is really a wonderfull project. We earn so much time using n8n in m’y company.

Hey @Kent1,

Officially this is on my list of things to fix still but it is just a case of finding the time. Once this is fixed we will post a message on here and the GitHub issue for it.

1 Like

@Kent1 We have the same problem. We try to do some POST requests to Wordpress API and get back

The connection to the server wes closed unexpectedly, perhaps it is offline. You can retry request immidiately or wait and retry later.

Can you write what changes you are doing inside docker to make it work? Something about NodeExecuteFunctions.js?

Thank you.