am working on dbcp connection pooling which I am trying to implement in an existing Java application(implemented in struts). I have noticed that in my java application none of the connections are closed. I am now trying to close those connections. The problem is whenever I use connection.close() I am getting an exception. Following is the error. Kindly help me to resolve this. Thanks in advance.
java.sql.SQLException: Connection is closed. at
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:185)
at
org.apache.tomcat.dbcp.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.prepareStatement(PoolingDataSource.java:312)
at .....................
Related
So every time I try to run a code, it first gives me that message and then just "Not connected". How can I fix this?
There is a very similar question Getting started with SLIME and SWANK: Lisp connection closed unexpectedly: connection broken by remote peer but I'm using Portacle and as far as I know it should take care of stuff like slime.
I have a web application running on an App Service on Azure cloud.
On the back-end I'm using a tcp connection to our database (Neo4j graph db), the best practice is to open the tcp connection and keep it alive in order to be more reactive when we perform queries.
The issue I encountered is that the database is logging the exception "Connection reset by peer";
reading on the web I found out that maybe Azure has a TCP timeout configured by default, I read it to be set up to 4 minutes, which could be my issue root cause.
Someone knows how to configure the tcp KEEP ALIVE to always for App Services on Azure?
I found on the web how to do it in Google cloud but nothing about Azure cloud.
Thank you in advance.
OaicStef
From everything I can find that is not an adjustable setting. Here is the forum link that says it will not be changing and that is a couple years old at this point. https://social.msdn.microsoft.com/Forums/en-US/32b76114-67a4-4e6b-ac45-61b0f0a0829f/changing-the-4-minute-request-time-out-for-app-services?forum=windowsazurewebsitespreview
I think you are going to have to add logic to your app that tests the connection, if it has been closed then either reopen it or create a new one. I don't know what language you are using to make any suggestions there.
Edit
I will add that the total number of TCP connections that can be open on a single App Service is about 6k, at least on the S1. Keep that in mind because if you don't have pooling on the server side or you are not disposing of those then you will exhaust that the TCP pool and you will start getting errors. I recommend you configure an alert for that.
There are a few questions related to this issue, but none of them actually help me understand what is going on.
The full error:
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request
It simply means that the client, i.e. the sites visitors, closed their connection.
Either by closing the browser, or through a connection error on their part.
Entity Framework 6 / Multi Layered Application / Connection Pooling is spiking and ultimately crashing our application by timing out and not allowing any further Connection Acquisition. We have gone through the code and standardized our connection strings and searched for any connections not being closed. Can anyone shed light on what might be causing this? We believe the area is at the connection acquisition level where too many requests for connections at once are happening. Not sure how to further test or dig for what is actually happening.
How can I can further troubleshoot and/or find causes to this problem?
We have our application deployed to WAS 6 cluster. And recently it is throring following exception.
javax.resource.ResourceException: The back-end resource is currently unavailable. Stuck connections have been detected.
......
Can somebody explain me why db connection was not released by the app and came back to free pool? How can I detect what is blocking connection to be released? I am planning to take thread dump every fee secs.
Everything was working fine and all of a sudden we started getting this exception, which is causing an issue with new user who is trying to login into the app.
Any input will be greatly appreciated. I have very little knowledge about WAS admin.
Thanks
Try using the PMI within the WAS console under Monitoring and Tuning, this will allow you to trace both the JDBC and thread pool usage in real time, I would definitely pay close attention to the WebContainer pool and see if the size of the pool tracks with the JDBC connection.
If the pools themselves are becoming exhausted you can increase the size to provide some legroom by upping the Maximum Connection Settings for the JDBC connection under Resources -> Data Sources -> $NAME -> Connection Pool, and the other connection pool settings under Server -> $SERVERNAME -> Additional Properties -> Thread Pool
Ensuring that the database your connecting to also has sufficent free connections would also be an idea! :)
If you are leaking pool connections, then its likely the code is missing a close connection somewhere.