H2 Database (Server) TCP connection timeout & connection pooling - tcp

I started the server and then application on a certain IP and Port from scratch (no dulpicate servers or port already used). The application was crashing due to java-lang-OutOfMemory error, saying that no new thread can be created. I allocated JVM 4G memory, and now that error is silent. But, now afterwards starting the client is crashing again. It runs for about 10-15 seconds and crash with SocketTimeoutException. Here is the trace
org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.SocketTimeoutException: connect timed out: MYIPADDRESS" [90067-172]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:407)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:295)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:105)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90)
at org.h2.Driver.connect(Driver.java:73)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at com.org.tseries.simulator.IPEmailSeriesTestDriver.shootH2(IPEmailSeriesTestDriver.java:201)
at com.org.tseries.simulator.IPEmailSeriesTestDriver.processSimulator(IPEmailSeriesTestDriver.java:160)
at com.org.tseries.simulator.IPEmailSeriesTestDriver.main(IPEmailSeriesTestDriver.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at org.h2.util.NetUtils.createSocket(NetUtils.java:119)
at org.h2.util.NetUtils.createSocket(NetUtils.java:100)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:95)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:403)
... 14 more
It is crashing when I run the client from terminal but when I ran the same client from STS (eclipse based IDE), it didnt crashed. Any setting or flag I need to add while running the client?
UPDATED: It is solved with appending AUTORECONNECT=TRUE in connection string. More details here, h2database.com/html/features.html#auto_reconnect
But now, I am interested in making a connection pool at Server end that allows different TCP clients to connect. The server shall serve the clients from the connection pool instead of clients reconnecting again. How can it be achieved?

Try open C:\Users\Superuser\db.lock.db. If this database already running you will see IP and port. Then in console type command netstat -ano. It will display all processes. Find PID of proccess that holds IP and port you found in .db file. Than you may kill this proccess using Task Manager or with help of command in console.
Another way: check all configs. You may use different IP in different configs. Synchronize this

Related

How do I solve a WSAECONNRESET error?

I am using Perforce as part of a small development team. Everyone was able to connect to the P4V client except for one person who gets the following error:
TCP receive failed.
read: socket: WSAECONNRESET
We have deactivated his McAfee firewall and virus scan, but the error persists. I really don't know what to do with this error and it seems to be rather undocumented on the perforce website. From what I gather, it's because it's not a perforce-specific issue, but rather a TCP communication problem that might be caused by something else.
Any tips?
a TCP communication problem that might be caused by something else.
This is possible, or it's possible that whenever this user connects it causes some sort of server fault.
https://msdn.microsoft.com/en-us/library/ms740668.aspx
WSAECONNRESET 10054 Connection reset by peer.
An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.
Beyond the usual connection troubleshooting questions (is this user on the same subnet? same version of the client software? same exact P4PORT setting? is the user able to connect via the command line client and if not does it give a more helpful error? why is this user unlike all other users?) I'd look at the server logs to see if it's logging any sort of more helpful error when this user tries to connect.

How to prevent ssh connection from timing out?

I got a problem with ssh connection.
I executed commands on a remote Linux server via python paramiko. The command executed for a long time(more than 40 minutes) and then returned the message which I want to check, there was no message returned during the executing.
I have tried different ways:
The ssh connection fails before the result returns if I don't change the sshd config on the remote server.
Enabled TCPKeepAlive/ClientAliveInterval/ClientAliveCountMax on the remote server, the server sent messages to the client during the idle period cyclically, the message was unhandled keepalive request...... It prevents the connection from timing out, but in this way, I can't get the message returned by the command.
Help me, thank you!

springboot embeded tomcat Acceptor thread missing

We are using springboot 1.3.3.RELEASE with embedded tomcat.
The service is running on redhat Linux 2.6.32 (64bit), using java 1.8.0_45.
In our load environment we noticed that the server is up (java VM is still running) and responding to non-HTTP requests, but HTTP requests exposed via SpringMVC Rest do not work, we get timeout.
After comparing thread dump between healthy and not-healthy system, we noticed in a non-healthy system the http-nio-{port}-Acceptor thread is missing.
In particular the dump shown bellow from a healthy machine is missing from bad one.
"http-nio-8080-Acceptor-0" #45 daemon prio=5 os_prio=0
tid=0x00007f13fb9ef800 nid=0x896b runnable [0x00007f146f3f4000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:422)
at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:250)
- locked <0x00000005cd5d0558> (a java.lang.Object)
at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:682)
at java.lang.Thread.run(Thread.java:745)
What could be reasons for the Acceptor thread to be missing?
Is it possible to restart the threat, without restarting the whole application?
Is that the reason we are not able to service HTTP requests?

Connection refused - not consistent

I have an application that is used to make hotel bookings. The application takes an XML message, transforms the XML into another XML message and sends this new XML to another application. I am able to book hotels successfully.
When I try to amend this booking (different XML request, same application, same URL) I get a 'Connection refused' error.
I would have thought that there'd be consistency (all work or none) but there's not.
Anyone any idea why?
"Connection refused" means that no application is accepting connections on the port and host that you try to connect to. It can be caused by
The application is actually running on a different host or a different port
The application crashed and hasn't been restarted
The application is buggy: it closes the listening server socket from time to time, so that it is not listening for connection attempts all the time
Firewall is configured to respond to new connections with a "connection refused" even if the application was able to accept a connection

Jax-ws java.net.ConnectException: Connection refused

I'm experiencing an odd networking problem connecting to a web service running on glassfish from a java client running on tomcat using JAX-WS (Metro). Here's the scenario...
Both servers are running on my local machine.
If I configure the client to connect to the WS endpoint using 127.0.0.1, the request works fine.
If I configure the client to connect to the WS endpoint using my IP address, I immediately get java.net.ConnectException: Connection refused. The same thing happens if I use my hostname.
The odd thing is that if I hit the endpoint from SoapUI, the request works fine if use 127.0.0.1, my IP address or my hostname.
Here's the exception I'm getting...
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.Socket.connect(Socket.java:529)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:120)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:256)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:184)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:137)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
at com.sun.xml.ws.client.Stub.process(Stub.java:323)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:113)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
at $Proxy51.listAttributeTypes(Unknown Source)
at com.myapp.store.service.client.JaxWsProductAdminServiceClient.listAttributeTypes(JaxWsProductAdminServiceClient.java:71)
at com.myapp.admintool.ProductAttributeController$_closure1.doCall(ProductAttributeController.groovy:26)
at com.myapp.admintool.ProductAttributeController$_closure1.doCall(ProductAttributeController.groovy)
at java.lang.Thread.run(Thread.java:680)
Any thoughts or pointers appreciated!
I have seen a similar problem when running the JAX-WS webservice on a linux box with an entry in /etc/hosts that points the computer's hostname to localhost.
This seems to cause the JAX-WS webservice to be started on http://localhost:port/endpoint and therefore only be accessible from that machine.
'Connection refused' means that there is nothing listening at the IP:port you specified. One or both of them is wrong.

Resources