GlassFish 3.1.2 HTTP connection slow after some time - glassfish

I am facing one critical issue. GlassFish 3.1.2(Oracle GlassFish final) server HTTP post methods are working only for first few minutes of GlassFish server restart. After some period of time HTTP connection takes 2 mins to initiate the request to the POST URL.
EDIT (from Comments): Java: jdk1.7 OS: Cent OS 7 64bit
After starting GlassFish server, I can access any URL using HttpUrlConnection. But after few minutes, It takes 2 minutes to initiate a request and get a response
For Example:
String msgURL = "someurl";
URL url = new URL(MsgURL);
HttpsURLConnection httpConnection = (HttpsURLConnection) url.openConnection();
if(null != httpsConn) {
System.out.println(httpsConn.getResponseCode()); }
If I restart the GlassFish server again, I am able to get response quickly. again after few minutes facing same slowness is sending reques
Can any one help me in this ?

I am not sure if you create always new connections. It may happen that all connections from the connection pool of the glassfish are in use, and you get a new connection after some of the connections times out. The timeout can explain the delay you are facing.

Related

Server sends "internal error" response faster after Tomcat upgrade

I recently upgraded our Tomcat server from 7.0.85 to 9.0.70. I am using Apache 2.4.
My Java application runs in a cluster, and it is expected that if the master node fails during a command, the secondary node will take the master role and finish the action.
I have a test that starts an action, performs a failover, and ensures that the secondary node completes the action.
The client sends the request and loops up to 8 times trying to get an answer from the server.
Before the upgrade, the client gets a read-timeout for the first 3/4 tries and then the secondary finishes the action, sends a 200 response, and the test passes. I can see in the Apache access log that the server is trying to send a 500 (internal error) response for the first tries, but I guess it takes too long and I get a read timeout before that.
After the upgrade, I am getting a read-timeout for the first try, but after that, the client receives the internal error response and stops trying. I can see that on the second try the Apache response is way faster than the first try and from the other tries (the 2,3,4 tries) before the upgrade.
I can see in the tcpdump that in the first try (both before and after the upgrade) the connection between the Apache and the Tomcat reaches the timeout. In the following tries the Tomcat sends the Apache a reset connection. The difference is, after the upgrade the Tomcat sends the reset connection immediately after the request, and before the upgrade, it takes a few seconds to send it.
My socket timeout is 20 seconds, the AJP timeout is 10 seconds (as it was before the upgrade). I am using the same configuration files as before the upgrade (except for some refactoring changes I had to do because of Tomcat changes). I tried changing the AJP timeout to 20 seconds, but it didn't help
Is this a configuration issue? Is there a way to “undo” this change?

How to stop Tomcat from processing old request / clear the cache?

In order to test the execution-time of some methods, I set around 250 requests to my backend, which uses Tomcat and Jersey.
Shortly after I realized that there was a mistake in the code, and changed it. Now I have to wait until Tomcat has finished processing all the previous requests. I tried restarting the Tomcat server and redeploying the backend, but no luck.
When i start the server it continues to process the "old" requests.
How do I flush the cache?

Time-out has expired. The time-out period has expired before a connection was obtained from the group

I am getting weird issue when i change deployment environment to my old ASP.net application . I migrated my ASP.net application from IIS 7 (windows server 2008 ) to IIS 8 (windows server 2012) ,application is running very well on old server but on new server i sometime get weird timeout issue . i have searched for my problem but i think i am the first one who is getting this issue :( . I even cant figure out, is this issue related to IIS timeout /session timeout or SQL timeout .
Time-out has expired. The time-out period has expired before a connection was obtained from the group. A possible cause is that all connections in the group have been in use and the maximum group was reached.
It looks like you have an application that isn't properly closing or disposing of the SqlConnection objects. By default, SqlConnection has a max pool size of 100.
The fix here would be to work with the application to find out why connections aren't being cleaned up, as they are still "active" in the particular connection pool, which is why you are unable to grab another one, because there are no inactive connections in the pool to use.
The application should be making a call to SqlConnection.Close() or SqlConnection.Dispose() in order to release the connection and mark it as "inactive".

Weblogic server failed to response under load

We have a quite strange situation on my sight. Under load our WL 10.3.2 server failed to response. We are using RestEasy with HttpClient version 3.1 to coordinate with web service deployed as WAR.
What we have is a calculation process that run on 4 containers based on 4 physical machines and each of them send request to WL during calculation.
Each run we see a messages from HttpClient like this:
[THREAD1] INFO I/O exception (org.apache.commons.httpclient.NoHttpResponseException) caught when processing request: The server OUR_SERVER_NAME failed to respond
[THREAD1] INFO Retrying request
The HttpClient make several requests until get necessary data.
I want to understand why WL can refuse connections. I read about WL thread pool that process http request and found out that WL allocate separate thread to process web request and the numbers of threads is not bounded in default configuration. Also our server is configured Maximum Open Sockets: -1 which means that the number of open sockets is unlimited.
From this thread I'd want to understand where the issue is? Is it on WL side or it's a problem of our business logic? Can you guys help to deeper investigate the situation.
What should I check more in order to understand that our WL server is configured to work with as much requests as we want?

How to configure Glassfish to drop hanging requests?

Can I configure Glassfish to drop any request that takes longer than 10 seconds to process?
Example:
I'm using Glassfish to host my web service. The thread pool is configured to have max 5 connections.
My service has a method that does this:
System.out.println("New request");
Thread.sleep(1000*1000);
I'm creating 5 requests to the service and I see 5 messages "New request" in the log. Then the server stop to respond for a looong time.
In live environment all requests must be processed in less than a second. If it takes more time to process then there is a problem with the request and I want Glassfish to drop such requests but stay alive and serve other requests.
Currently I'm using a workaround in the code. At the beginning of my web method I launch a separate thread for request processing with a timeout as it was suggested here: How to timeout a thread
I do not like this solution and still believe that there must be a configuration setting in the Glassfish to apply this logic to all requests, not to just one method.