Prevent dropping a persistent connection - java

We are using Talend and rest web services to store data on Heroku. After some idle time our persistent connection gets dropped. I have search postgresql documentation but I cannot find any parameter that sets the timeout for the idle connection. Issues we are facing are following:
Exception in component tPostgresqlInput_2
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:281)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:403)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:283)
at ulu.loaderherokueventsdbg_0_1.LoaderHerokuEventsDBG.tPostgresqlInput_2Process(LoaderHerokuEventsDBG.java:856)
at ulu.loaderherokueventsdbg_0_1.LoaderHerokuEventsDBG.tJava_2Process(LoaderHerokuEventsDBG.java:617)
at ulu.loaderherokueventsdbg_0_1.LoaderHerokuEventsDBG.tPostgresqlConnection_1Process(LoaderHerokuEventsDBG.java:1260)
at ulu.loaderherokueventsdbg_0_1.LoaderHerokuEventsDBG.tLibraryLoad_2Process(LoaderHerokuEventsDBG.java:1114)
at ulu.loaderherokueventsdbg_0_1.LoaderHerokuEventsDBG.runJobInTOS(LoaderHerokuEventsDBG.java:2231)
at ulu.loaderherokueventsdbg_0_1.LoaderHerokuEventsDBG.main(LoaderHerokuEventsDBG.java:1992)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(Unknown Source)
at java.net.SocketOutputStream.write(Unknown Source)
at sun.security.ssl.OutputRecord.writeBuffer(Unknown Source)
at sun.security.ssl.OutputRecord.write(Unknown Source)
at sun.security.ssl.SSLSocketImpl.writeRecordInternal(Unknown Source)
at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
at sun.security.ssl.AppOutputStream.write(Unknown Source)
at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
at java.io.BufferedOutputStream.flush(Unknown Source)
at org.postgresql.core.PGStream.flush(PGStream.java:518)
at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:1141)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:254)
... 9 more
From this site I could read that the cause for the dropped connection is probably not in the database but in the tcp layer. Do you have any suggestion how to solve the issue?

I just guessing but there can be a problem with a timeouts or idle time.
There could be other problems with network itself or your back-end responded with something that client do not understand.
I can see you are using PostgreSQL?
I am just guessing but try to comment out this line: synchronous_standby_names = '*'
in postgresql.conf it will prevent client to wait and got time-out when waiting for a response from a server.
But as I said I just guessing here...

Related

connection to Cloudera Impala / Hive outside the cluster

i am working with cloudera impala server version 5.4.7
first to make sure the port is open i have validate it with telnet.
Class.forName("org.apache.hive.jdbc.HiveDriver");
DriverManager.setLoginTimeout(30);
try (java.sql.Connection connection = DriverManager.getConnection("jdbc:hive2://12.23.56.789:123456/someName;auth=noSasl"))
{ System.out.println("connected"); }
But i never succeed to connect
all i get is this error from timeout:
what could be the problem ?
i am using the exact same hive version as the cloudera version
[14 Apr 2016 06:27:26,797] [ERROR] [main] [org.apache.hive.jdbc.HiveConnection] - Error opening session
org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:129)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:429)
at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:318)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:219)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at org.apache.hive.service.cli.thrift.TCLIService$Client.recv_OpenSession(TCLIService.java:156)
at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:143)
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:475)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:181)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.datorama.core.service.delivery.providers.DatabaseProvider.main(DatabaseProvider.java:330)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:127)
... 13 more
Exception in thread "main" java.sql.SQLException: Could not establish connection to jdbc:hive2://54.69.2.250:21050/sage_global;auth=noSasl: java.net.SocketTimeoutException: Read timed out
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:486)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:181)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.datorama.core.service.delivery.providers.DatabaseProvider.main(DatabaseProvider.java:330)
Caused by: org.apache.thrift.transport.TTransportException: java.net.SocketTimeoutException: Read timed out
at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:129)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:429)
at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:318)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:219)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at org.apache.hive.service.cli.thrift.TCLIService$Client.recv_OpenSession(TCLIService.java:156)
at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:143)
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:475)
... 5 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:127)
... 13 more
We do a good deal of querying from outside the cluster using JDBC. While I believe it may be possible to use the Hive JDBC driver, you'll certainly need to set a proper port in your JDBC connections string, likely 21050 for Impala. You'll need to ensure that your host name (or IP address) points to an instance running the Impala daemon (for Hive you might point to a namenode). My guess is that the port number is wrong, as it seems that the error is simply failure to establish a top connection.
We decided to use the specific driver supplied by Cloudera for Impala, although that may not be necessary. We also set up a load balancer so there is one stable address to direct queries to, rather than requiring the caller to pick a specific Impala instance. This also spreads the load evenly and let's us make changes in the cluster without external callers needing to change anything.

JDBC The Network Adapter could not establish the connection/Connection reset/recv failed

I currently have a application running that needs data from a database to be able to work properly.
Here are the specifics:
Glassfish 3.1.2
Oracle DB 11.2.0.2.0 (I have limited access here)
Java 7/JEE6
JDBC Lib oracle-jdbc-11.2.0.3-jdk6.jar
I use pooling with a standard configuration by Glassfish when a new connection pool is created
The SQLs used are only selects with no joins or other complex structures within
They run easily under 30 sec and below depending on the SQL
My problem is that I get the following error messages in infrequent intervals which results in missing data or complete shutdown of the JDBC resource.
[#|2015-10-22T16:25:42.400+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator|_ThreadID=461;_ThreadName=Thread-2;|RAR5038:Unexpected exception while creating resource for pool jdbc. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: I/O-Fehler: The Network Adapter could not establish the connection|#]
Followed by
[#|2015-10-22T19:10:47.787+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool|_ThreadID=461;_ThreadName=Thread-2;|RAR5035:Unexpected exception while destroying resource from pool jdbc. Exception message: Error while destroying resource :I/O-Fehler: Unrecognized Windows Sockets error: 0: recv failed|#]
[#|2015-10-22T19:10:48.052+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool|_ThreadID=461;_ThreadName=Thread-2;|RAR5035:Unexpected exception while destroying resource from pool jdbc. Exception message: Error while destroying resource :I/O-Fehler: Connection reset|#]
Followed by
[#|2015-10-22T19:11:33.287+0200|WARNING|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.pool|_ThreadID=461;_ThreadName=Thread-2;|RAR5035:Unexpected exception while destroying resource from pool jdbc. Exception message: Error while destroying resource :I/O-Fehler: Socket read timed out|#]
Followed by (removed non relevant parts from my impl with ....)
#|2015-10-23T16:35:00.087+0200|SEVERE|glassfish3.1.2|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource|_ThreadID=576;_ThreadName=Thread-2;|RAR5031:System Exception
javax.resource.spi.LocalTransactionException: Getrennte Verbindung
at com.sun.gjc.spi.LocalTransactionImpl.rollback(LocalTransactionImpl.java:134)
at com.sun.enterprise.resource.ConnectorXAResource.rollback(ConnectorXAResource.java:213)
at com.sun.enterprise.transaction.JavaEETransactionImpl.rollback(JavaEETransactionImpl.java:571)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.rollback(JavaEETransactionManagerSimplified.java:893)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5126)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4915)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at com.sun.proxy.$Proxy248.loadData(Unknown Source)
....
at sun.reflect.GeneratedMethodAccessor1663.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
....
at sun.reflect.GeneratedMethodAccessor1559.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:149)
at sun.reflect.GeneratedMethodAccessor1563.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348)
at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:4058)
at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1832)
at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:108)
at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:2646)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.sql.SQLRecoverableException: Getrennte Verbindung
at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:3921)
at com.sun.gjc.spi.LocalTransactionImpl.rollback(LocalTransactionImpl.java:128)
... 50 more
I have programmatic fail safe which opens a new transaction to avoid a ManagedException within in my application and retries three times in case of failure.
However this is apparently to not enough to ensure the stability of the JDBC connection.
What is the problem here?
So here's what I tried and worked.
IO Error: The Network Adapter could not establish the connection
-> Database was running, URL was correct, Firewall was tested with a custom ping script
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind (JBOSS) -> The pc was a win7 machine however the argument -Djava.net.preferIPv4Stack=true didn't help
The network adapter could not establish the connection - Oracle 11g -> Replaced my original jdbc 6 Jar with new one listed above, didn't solve the problem
Java JDBC connection status -> This got my thinking
After seeing the post in 4. I tried several configurations in Resources -> JDBC -> JDBC Connection Pools -> jdbc for timeouts etc. I though using
select 1 from SOME_TABLE;
to be the solution. Unfortunately I made the mistake use it like this
Instead of this
The difference by my understanding is that the first validates the connection when it goes into the pool. The second validates it when it's given out the pool to be used by a resource.
Now it seems to work fine.
I hope this helps!

Failed to connect to MySQL database

I get this console error every time I try to run this rs private server. Pretty much everything is connected to a mysql db.
I've been messing around with this for quite awhile but can't figure out whats wrong. If there is any specific files you may need to look at to help me figure out whats wrong, tell me and I'll post it.
All help would be highly appreciated!
[Stage - 1] Launching Elunity...
[Stage - 2] Loaded object configurations
[Stage - 3] Loaded region configurations
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 1 432 637 479 787 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
Failed to connect to MySQL database
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2214)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at paladious.model.players.Highscores.process(Highscores.java:17)
at paladious.Server.main(Server.java:117)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 1 432 637 479 777 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2137)
... 13 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:290)
... 14 more
[Stage - 4] Loaded single event manager
[Stage - 7] Loaded NPC drops
[Stage - 8] Loaded player punishments and starters
[Stage - 10] Elunity online on port :43594
Thanks in advance! :)
This is a wrapped exception and not really interesting. It is the root cause of the exception which actually tells us something about the root cause. Please look a bit further in the stacktrace. The chance is big that you'll then face a SQLException: Connection refused or SQLException: Connection timed out.
If this is true in your case as well, then all the possible causes are:
IP address or hostname in JDBC URL is wrong.
Hostname in JDBC URL is not recognized by local DNS server.
Port number is missing or wrong in JDBC URL.
DB server is down.
DB server doesn't accept TCP/IP connections.
Something in between Java and DB is blocking connections, e.g. a firewall or proxy.
To solve the one or the either, follow the following advices:
Verify and test them with ping.
Refresh DNS or use IP address in JDBC URL instead.
Verify it based on my.cnf of MySQL DB.
Start it.
Verify if mysqld is started without the --skip-networking option.
Disable firewall and/or configure firewall/proxy to allow/forward
the port.

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake while load Test using JMeter

I am doing the load test using JMeter of my web application which is hosted on tomcat 7 with SSL configured.
My load test is working fine for 100,200,300,500 https get requests, URL is below:
https://testapi.myapp.com/myapptor/tempo/getinfo?id=4E92D41E&groupid=test
But when i m trying to put more load say 600 or greater than 600 requests, I am getting below error as response for some of the get requests whereas some of the get request having the correct response data:
javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:436)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.jmeter.protocol.http.sampler.MeasuringConnectionManager$MeasuredConnection.open(MeasuringConnectionManager.java:107)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:517)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:331)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1146)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1135)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:434)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:261)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at sun.security.ssl.InputRecord.read(Unknown Source)
... 20 more
Can you please advice me, why I am getting above error and who is that Remote host mentioned in error?
My tomcat server have max threads to 300 and accept count to 100.
That's exactly the kind of thing that starts happening when the load is too great for your system. 'Remote host' means the tomcat instance.
Either accept that 500 connections is the most your system will handle, or start investigating scaling up.
This might be a bug in Tomcat that has recently been fixed. Please have a look at this bug report and see if it matches your issue.

Java and MySql connection problem

I am using Java+MySql. I am trying to add bulk data (around 40 million records). My application works fine for couple of hundred thousands records but after that it starts giving me following exception:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1116)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:344)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2333)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2370)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2154)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.GeneratedConstructorAccessor5.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at net.jboss.Database.DatabaseConnection.getConnection(DatabaseConnection.java:48)
at net.jboss.emp.idm.adta(mde.java:96)
at net.jboss.emp.idm.main(mde.java:69)
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:257)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:294)
... 16 more
I googled this problem and tried almost every option (updating windows registry, changing my.cnf file, changing mysql global parameters etc.) but its not working.
I was hitting a similar problem a couple of hours ago. With the default settings, I could write some 15K records in a single transaction. Attempting to write any more than that gave me the exact same message ("No buffer space available (maximum connections reached?): connect") .
I then broke down the transactions in chunks of 1000 records (my application requirements allowed for it) and I still received the message after the 15th iteration. My application was diligently creating a new EntityManager and closing it for each iteration.
The solution was to clear the cache for that particular type of entity in between iterations (you can also clear the cache by entity) .
EntityManagerFactory.getCache().evictAll or evict(...)
It seems connection isn't being closed properly. I would recommend you to use connection-pooling
Also See
Connection pooling with MySQL Connector/J
this could be probably either lost connection with mysql or
your code could not be able to close existing connetction as u said it work for starting some records. so incresce max connection with mysql or try to check with other program when u get this error message if mysql accept connection from other program.
I was having the exact same problem and I fixed it by connectionname.close(); statement after every time an executable statement is called.
this can resolve your issue now :)
CommunicationsException

Categories