Caused by: java.net.SocketTimeoutException: Read timed out - spring-boot

I have a spring boot 2.x application that is making a soap call using JaxWsProxyFactoryBean to make the calls. All of the calls are working flawlessly except for one that is getting "java.net.SocketTimeoutException: Read timed out". Things to note:
My application is having no problems with soap calls within my network.
The only soap call having an issue is outside of my network and the issue is sporadic
From network traces it also appears my application is reusing connections (connection pooling)
My application makes millions of calls per day to both the internal (working soap serivces) and the external service that is having the blips
Questions:
How do I configure http connection pooling in spring boot 2.0?
Is it likely the issue will go away if I disable HTTP connection pooling?
What type of performance hit (estimate in ms) am I looking at if I disable HTTP connection pooling?
What could the causes of my issue be if its not related to the connection pool?
If you need any other details please let me know.
Partial Stack Trace:
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:975)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:933)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:735)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1587)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream$2.run(URLConnectionHTTPConduit.java:377)
at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream$2.run(URLConnectionHTTPConduit.java:373)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.transport.http.URLConnectionHTTPConduit$URLConnectionWrappedOutputStream.getResponseCode(URLConnectionHTTPConduit.java:373)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.doProcessResponseCode(HTTPConduit.java:1597)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1625)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1570)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1371) ...
Thanks,
Brian

Related

HikariPool-1 - Connection is not available -webclient

I have some client class to external data provider.
In this class, I'm using webclient reactive client and crud repository.
Webclient uses repo to save responses from client (business requirement). For instance in onError, onStatus etc methods uses this repository. We performed load tests and it's working well.
The problem is when external API is not working and we're retrying couple of times (exponential backoff). Then I get:
HikariPool-1 - Connection is not available, request timed out after 30005ms
org.springframework.dao.DataAccessResourceFailureException: Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
So it seems like webclient is keeping connection while retrying for 30 seconds and we're running out of connections. Extending connection pool size is not the way I want to fix that.
Is there any way to release connection while webclient is jsut waiting for another retry and so on?

Spring RestTemplate call fails intermittently with 'SocketException: Connection reset'

The following exception i am getting when our application is consuming the Rest endpoint using spring boot RestTemplate.
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://xxxxxxxxxx:123456/xxxxx/xxxxx/xxxxxx/xxxx":
Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset; nested exception is javax.net.ssl.SSLException:
Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:741)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:684)
at org.springframework.web.client.RestTemplate.postForEntity(RestTemplate.java:466)
This issue we are getting intermittently. some time more than 2 to 3 times.
I couldn't find any information specific to this issue ?
Does any one faced same issue and how its resolved?
Do the CURL on the endpoint you are trying to access using RESTTemplate and see if your machine has access to that URL?
If Yes-->Let me know and still getting an error, Let me know I will update the answer:)
If No-->that the problem I had the same issue for facebook API.

Unable to acquire JDBC Connection in SpringBoot app

I have a Microservices‑Based Application, each Microservice is a SpringBoot 2.0.3.RELEASE app., but after my 4rth Microservices launched I have this error:
Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
..
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connections
I would like to know how to reduce the maximumPoolSize or if there is a way to know maximumPoolSize because I have't seen anything related when the app starts
You can set the maximum pool size of the JDBC connections in your application.properties file like:
spring.datasource.hikari.maximum-pool-size=5

Configure Weblogic Message Queue listener in Websphere

I have the below requirement to be met:
Say I have configured a JMS server, a JMS queue and a connection factory in WebLogic. Now, the message sender lies in the same WebLogic instance and able to send messages to the queue successfully. The listener part also works fine if they are in the same WebLogic instance.
Now, my requirement is, the message listener will be part of an entirely different web application deployed on WebSphere Application Server. So basically I am trying to listen to a WebLogic queue from a WebLogic server. I have tried to google the solution and found concepts like "Foreign JMS Server" and "Message Bridges" in WebLogic. What I have understood from those is that, it forwards the incoming message(in my case WebLogic queue) to a remote destination (WebSphere in my case). Then in the remote destination, I can deploy a listener configured as if it is listening to a local JMS queue. Is this understanding correct? In either case, what other options do I have? I don't have any requirement that the message needs to be directly available to my WebSphere queue as long as I am able to read the messages even from a remote message queue. so, if technically possible, the message forwarding is a bit overkill for my need. Any guidance or suggestion on this would be really helpful.
UPDATES:
I have tried the exact steps mentioned in both of those articles:
http://middlewaretimes.blogspot.in/2014/06/how-to-configure-weblogic-server-with.html
http://ibswings.blogspot.in/2008/02/integrating-mq-broker-6-with-bea.html
Since I want to use spring JMS, I have written the sender and receiver myself following this tutorial. However, now I am stuck at the following exception:
org.springframework.jms.InvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'jms/WLReceiverQueue'.; nested exception is com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'jms/WLReceiverQueue'.
JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.; nested exception is com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2085' ('MQRC_UNKNOWN_OBJECT_NAME').
at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:285)
at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:496)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:579)
at InvoiceQueueSender.sendMesage(InvoiceQueueSender.java:23)
at InvoiceSenderServlet.service(InvoiceSenderServlet.java:17)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3432)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused by: com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'jms/WLReceiverQueue'.
JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.
at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:503)
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:221)
at com.ibm.msg.client.wmq.internal.WMQMessageProducer.checkJmqiCallSuccess(WMQMessageProducer.java:1061)
at com.ibm.msg.client.wmq.internal.WMQMessageProducer.checkJmqiCallSuccess(WMQMessageProducer.java:1019)
at com.ibm.msg.client.wmq.internal.WMQMessageProducer.access$800(WMQMessageProducer.java:68)
at com.ibm.msg.client.wmq.internal.WMQMessageProducer$SpiIdentifiedProducerShadow.initialise(WMQMessageProducer.java:765)
at com.ibm.msg.client.wmq.internal.WMQMessageProducer.(WMQMessageProducer.java:995)
at com.ibm.msg.client.wmq.internal.WMQSession.createProducer(WMQSession.java:886)
at com.ibm.msg.client.jms.internal.JmsSessionImpl.createProducer(JmsSessionImpl.java:1232)
at com.ibm.msg.client.jms.internal.JmsQueueSessionImpl.createSender(JmsQueueSessionImpl.java:136)
at com.ibm.mq.jms.MQQueueSession.createSender(MQQueueSession.java:153)
at com.ibm.mq.jms.MQQueueSession.createProducer(MQQueueSession.java:254)
at org.springframework.jms.core.JmsTemplate.doCreateProducer(JmsTemplate.java:1142)
at org.springframework.jms.core.JmsTemplate.createProducer(JmsTemplate.java:1123)
at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:600)
at org.springframework.jms.core.JmsTemplate$4.doInJms(JmsTemplate.java:583)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:493)
... 21 more
Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2085' ('MQRC_UNKNOWN_OBJECT_NAME').
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:209)

Websphere HttpClient java.lang.NoSuchMethodError: org/apache/http/conn/ssl/SSLSocketFactory.<init>

I have a webapp that needs to be deployed to Websphere 8.5, (it works fine in tomcat 7). This app calls the REST webservice of another app, and uses HttpClient for that. When I start the app I get the following error:
Caused by: java.lang.NoSuchMethodError: org/apache/http/conn/ssl/SSLSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Lorg/apache/http/conn/ssl/X509HostnameVerifier;)V
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.initDefaultEngine(ResteasyClientBuilder.java:418)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:333)
at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:49)
at javax.ws.rs.client.ClientBuilder.newClient(ClientBuilder.java:114)
at com.qmino.matrix.calculation.engine.EngineInstance.<init>(EngineInstance.java:23)
at com.qmino.matrix.calculation.engine.CalculationEngine.<init>(CalculationEngine.java:61)
at com.qmino.matrix.calculation.engine.ThreadPool.<init>(ThreadPool.java:29)
at com.qmino.matrix.calculation.engine.application.Application.getThreadPool(Application.java:53)
at com.qmino.matrix.calculation.engine.application.Application$$EnhancerBySpringCGLIB$$57778e16.CGLIB$getThreadPool$0(<generated>)
at com.qmino.matrix.calculation.engine.application.Application$$EnhancerBySpringCGLIB$$57778e16$$FastClassBySpringCGLIB$$d67ab8c2.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at com.qmino.matrix.calculation.engine.application.Application$$EnhancerBySpringCGLIB$$57778e16.getThreadPool(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 120 more
I've found this question but it wasn't really helpfull. Can anybody help me with this?
Httpclient libraries conflict with WebSphere provided. Please try to create isolated shared library via Environment > Shared libraries, put the http client jars there and map that library to the application. See more details in this post WebSphere 8.5 and Apache HTTP Client

Resources