-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
ECONNRESET with unpooled connection / close #1344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like something is killing your connection attempt. Can you connect at all to the postgres server from node-postgres? Is it just in this particular scenario? If you do |
Hello, I have same problem with
Here is how I'm making query:
Same when I'm doing query this way:
Also it's worth to add that after I disabled ssl on postgres and set |
Your suggestion from #314 worked for me (adding |
I have a use case similar to @aahoughton and @wadik12. Modifying connection.js with the edit from #314 cleared the error for me as well. |
Same issue with Node and Azure hosted Postgres, been debugging this all day long. And yes, the problem is when you use SSL: true. |
@paoliniluis - I can't reproduce this locally or in any CI environment. Do you have an environment I can use to reproduce the issue? Without a reliable way to reproduce this or PR with test + fix I'm afraid there isn't a lot i can do to help fix the issue from where I sit. |
OOC, have you tested against an azure-hosted instance (maybe you have, it's not clear)? Azure apparently provides $200 of free usage; barring that, I'm happy to set up a PG instance in their cloud using my account -- which I'll need to create -- and give you permissions. Note that I'm not familiar with their admin console, so it may take a few. |
@aahoughton are you able to set up an environment to @brianc? I can set up a video call and help you set up a postgre in Azure if needed. Send me an email directly |
I just set one up (thank you for the offer, though). @brianc email incoming. |
hey @aahoughton, were you able to find any solution to this? thanks! |
@wadik12 Why did you close your PR by yourself? |
@cryptcoin-junkey If there is a problem, the patch might only hide it (rather than solve it). It’s important to find out exactly what’s going wrong first. |
@charmander I see. I've additional info. This may depend on runtimes. Just in my case. |
@cryptcoin-junkey I closed it because there was to many changes in the meantime, and I thought it's already been solved. |
I'm getting the same error as soon as I call end. I'm running on a Windows 10 dev machine against a PG server hosted in Azure, so perhaps that's part of the problem. I'd be glad to give you access to my machine for testing if you want. |
@wadik12 Thanks for your reply. Actually your patch is still effective as can be seen by reading comments... |
worked for me. by disabling ssl on Azure with the above fix #1386 |
Not worked for me. I disable SSL on Azure, but I steel get an error: "SSL connection is required. Please specify SSL options and retry" |
I'm having a very similar issue with Azure PostgreSQL, and spent a while debugging this. I think I figured out what's happening. I tried aahoughton's code snippet (the first in this issue) first against a local Postgresql server first, and inspected traffic with Wireshark. When Connection.prototype.end() is called (and the "0x58" command is sent), the server replies with TLS "close_notify" alert, and the client then cleanly closes the TCP connection. (And the code snipped works just fine) When I run the same code against Azure Postgresql, the server immediately replies with a TCP RST (=ECONNRESET). In Connection.prototype.connect, there's code handling this for the non-SSL case:
And about 30 lines later, we have the code for TLS:
...which is missing the test for @brianc, I can't think of any easy way to trigger this situation on CI, would you accept a PR without tests? |
@brianc any update about this problem? Because it's still occur. |
Seems to be solved by @pasieronen but still not implemented in node-postgres code and the sheeet numer of devs still wasting time on debugging it , as me now ;) |
Any idea on when the above PR will be merged? Would love to remove the workarounds in our code base written to avoid this issue. |
Also just ran into this... |
Fixed in pg 7.4.1 by #1537. |
Yes, fixed with 7.4.1, thanks! (Wherever the question went) |
@Elexy It’s happening when you call |
@charmander Sorry I deleted my comment again, because with the code stripped to the minimum I don't see the error. So I am expecting it is in another part of the code. When I turn on logging I see:
Sometimes the |
@aahoughton how did you get the second part of your error, below the `---------------------':
|
I can confirm that another part of my code caused the ECONNRESET. |
It seems that 7.4.1 didn't fix the issue on our end. We've also tried the undocumented option const databaseConfig: PoolConfig & { keepAlive: boolean } = {
keepAlive: true,
connectionTimeoutMillis: 10000, // 10 seconds
max: 10,
}; I can't seem to figure out where the issue is coming from, to be honest. |
@Magellol are you on Azure with SSL as well?
|
@Elexy Ah sorry no we're not on Azure. Didn't notice this thread was mostly about it, my bad. Thanks for the snippet though! We're on Kubernetes so I'm not sure it's an environment issue or not. Seems like you guys have some troubles as well on your environment. I can't figure out where the problem might come from, |
Yes, I now found out that migrating the DB with postgrator it's using an unpooled connection and it never makes it past When I change
to
It all begins to work again. ** update **
So it's probably not correct :-) |
@Elexy And you’re sure postgrator is using 7.4.1 as well? |
@charmander sorry for hijacking the issue, but yes, it's using 7.4.1
|
@charmander I had several go's at a PR fixing this, but no luck. The tests are not passing: I lack in depth knowledge of the PG protocol. |
I've been stuck in the follow error after runing request, which querying from localhost pg db.
Error details:
Error in project:
The database log is Here is the pg-pool index.js(version 1.8.0) section:
Connect parameters:
Envrionment:
Finally I find if I change the container's export port, which is different from localhost enterprisedb instance(it's status is exit, not up) port, the error message disappeared. For anyone who might suffer same pain here. |
I'm only recently seeing this too. Wonder if it's a regression? |
Same problem here! I'm using node-postgres with Google Cloud Functions which kills connections every 2min. This causes ECONNRESET which kills the process. Has anyone found a workaround? KeepAlive=true doesn't help. |
We're in the process of bringing up our (normally AWS-based) stack on azure with a hosted PG instance. Azure apparently requires SSL (which may or may not be important, but it's in the stack trace, so..)
We're running into issues with unpooled connections (used to verify DB availability) in our periodic DB status tests. node version is 6.9.0; node-postgres version is 6.4. Code looks like this (w/o longjohn):
.. errors (after 5s) with this:
.. seems like it may be related to #314 but unclear.
The text was updated successfully, but these errors were encountered: