John Mills
John Mills

Reputation: 10263

Node.js App Keeps Getting ECONNRESET Error When Calling Into WSL 2

Running on Windows 10 with WSL 2, I have a Node.js App (App1) that I'm trying to load test using another Node.js App (App2). App2 mocks the HTTP services that App1 depends on i.e. AWS & Salesforce APIs. The Salesforce portion, uses the CometD protocol to push messages to App1.

App2 is running on Ubuntu in WSL 2. App1 is running on Windows 10. Both are on the same physical machine.

When I push thousands of messages to App1 over CometD (HTTP long-polling), App1 starts choking and receiving the following error:

error: {
  "errno": -4077,
  "code": "ECONNRESET",
  "syscall": "read"
}

I kill App1 and restart it, but it continues to receive the same error. It doesn't matter whether I'm running App1 via VSCode or just using node from the command line.

Strangely, I can use CURL from bash on WSL 2 to make requests to App2 and it works fine. The only way I can get App1 talking to App2 again, is to restart the computer.

Why does this happen and is there a way I can fix it without having to restart Windows?

Upvotes: 3

Views: 1111

Answers (1)

John Mills
John Mills

Reputation: 10263

Restarting WSL 2 works (temporarily), and doesn't require restarting Windows.

From the command line, run:

wsl --shutdown

Upvotes: 1

Related Questions