title: Spring Boot calling rest ws SocketTimeoutException connect timed out
body: <p>I have developed a spring boot application, this app simply makes web service calls to another system. I have thousands of web service call tasks(Callable or supplier). Thats why I send 40 tasks per second in parallel. Target system that I send requests to has enough resource to handle thousands of request.When I start to send requests everything is fine but after a while I realize that from time to time my spring boot app get <strong>java.net.SocketTimeoutException: connect timed out</strong></p>
  
  <p>Target system is a rest web service, I used <strong>moxy</strong> implementation of <strong>JAXB</strong> in my Spring boot app while calling this target ws</p>
  
  <p>Pls help me about this socket connect timeout, is there any configüration that I have to know about high volume web service call on spring boot app(embeded Tomcat)</p>
  
  <p>Here is the exception full stacktrace : </p>
  
  <pre><code>javax.ws.rs.ProcessingException: HTTP 500 Internal Server Error
      at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:287)
      at org.glassfish.jersey.client.JerseyInvocation.lambda$invoke$0(JerseyInvocation.java:753)
      at org.glassfish.jersey.client.JerseyInvocation.dt_access$570(JerseyInvocation.java)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:316)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:298)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:229)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:414)
      at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:752)
      at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:445)
      at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:351)
      at com.cvk.pricing.cache.client.pricing.BrandedFareServiceClient.shoppingSearch(BrandedFareServiceClient.java:62)
      at com.cvk.pricing.cache.task.BrandedFareSearchTask.get(BrandedFareSearchTask.java:53)
      at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
      at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
      at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
      at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:747)
      at java.util.stream.ReduceOps$ReduceTask.doLeaf(ReduceOps.java:721)
      at java.util.stream.AbstractTask.compute(AbstractTask.java:316)
      at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
      at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
      at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
      at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
      at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
  Caused by: javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error
      at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:959)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:266)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:251)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:163)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1135)
      at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:516)
      at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:498)
      at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:384)
      at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:282)
      at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
      ... 23 more
  Caused by: javax.xml.bind.MarshalException
   - with linked exception:
  [Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.XMLMarshalException
  Exception Description: An error occurred marshalling the object
  Internal Exception: java.net.SocketTimeoutException: connect timed out]
      at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:500)
      at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:957)
      ... 32 more
  Caused by: Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.XMLMarshalException
  Exception Description: An error occurred marshalling the object
  Internal Exception: java.net.SocketTimeoutException: connect timed out
      at org.eclipse.persistence.exceptions.XMLMarshalException.marshalException(XMLMarshalException.java:104)
      at org.eclipse.persistence.oxm.record.JSONWriterRecord$OutputStreamOutput.write(JSONWriterRecord.java:1016)
      at org.eclipse.persistence.oxm.record.JSONWriterRecord$OutputStreamOutput.writeLocalName(JSONWriterRecord.java:1083)
      at org.eclipse.persistence.oxm.record.JSONWriterRecord.writeKey(JSONWriterRecord.java:634)
      at org.eclipse.persistence.oxm.record.JSONWriterRecord.openStartElement(JSONWriterRecord.java:264)
      at org.eclipse.persistence.oxm.record.JSONWriterRecord.attribute(JSONWriterRecord.java:438)
      at org.eclipse.persistence.internal.oxm.XMLDirectMappingNodeValue.marshalSingleValue(XMLDirectMappingNodeValue.java:89)
      at org.eclipse.persistence.internal.oxm.XMLDirectMappingNodeValue.marshal(XMLDirectMappingNodeValue.java:65)
      at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:102)
      at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:59)
      at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:443)
      at org.eclipse.persistence.internal.oxm.XPathObjectBuilder.marshalAttributes(XPathObjectBuilder.java:565)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.marshalAttributes(TreeObjectBuilder.java:122)
      at org.eclipse.persistence.internal.oxm.XPathNode.startElement(XPathNode.java:469)
      at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.marshalSingleValue(XMLCompositeCollectionMappingNodeValue.java:324)
      at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.marshal(XMLCompositeCollectionMappingNodeValue.java:104)
      at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:149)
      at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:102)
      at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:59)
      at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:443)
      at org.eclipse.persistence.internal.oxm.XPathObjectBuilder.buildRow(XPathObjectBuilder.java:243)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:118)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:1)
      at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.marshalSingleValue(XMLCompositeCollectionMappingNodeValue.java:334)
      at org.eclipse.persistence.internal.oxm.XMLCompositeCollectionMappingNodeValue.marshal(XMLCompositeCollectionMappingNodeValue.java:104)
      at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:149)
      at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:102)
      at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:59)
      at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:443)
      at org.eclipse.persistence.internal.oxm.XPathObjectBuilder.buildRow(XPathObjectBuilder.java:243)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:118)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:1)
      at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshalSingleValue(XMLCompositeObjectMappingNodeValue.java:260)
      at org.eclipse.persistence.internal.oxm.XMLCompositeObjectMappingNodeValue.marshal(XMLCompositeObjectMappingNodeValue.java:151)
      at org.eclipse.persistence.internal.oxm.NodeValue.marshal(NodeValue.java:102)
      at org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext.marshal(ObjectMarshalContext.java:59)
      at org.eclipse.persistence.internal.oxm.XPathNode.marshal(XPathNode.java:443)
      at org.eclipse.persistence.internal.oxm.XPathObjectBuilder.buildRow(XPathObjectBuilder.java:243)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:118)
      at org.eclipse.persistence.internal.oxm.TreeObjectBuilder.buildRow(TreeObjectBuilder.java:1)
      at org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal(XMLMarshaller.java:766)
      at org.eclipse.persistence.internal.oxm.XMLMarshaller.marshalStreamOrWriter(XMLMarshaller.java:1147)
      at org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal(XMLMarshaller.java:934)
      at org.eclipse.persistence.internal.oxm.XMLMarshaller.marshal(XMLMarshaller.java:877)
      at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:496)
      ... 33 more
  Caused by: java.net.SocketTimeoutException: connect timed out
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      at java.net.Socket.connect(Socket.java:589)
      at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
      at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
      at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:242)
      at sun.net.www.http.HttpClient.New(HttpClient.java:339)
      at sun.net.www.http.HttpClient.New(HttpClient.java:357)
      at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)
      at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
      at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
      at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)
      at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)
      at org.glassfish.jersey.client.internal.HttpUrlConnector.lambda$_apply$0(HttpUrlConnector.java:382)
      at org.glassfish.jersey.client.internal.HttpUrlConnector.dt_access$717(HttpUrlConnector.java)
      at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:195)
      at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:189)
      at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:223)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:300)
      at org.eclipse.persistence.oxm.record.JSONWriterRecord$OutputStreamOutput.write(JSONWriterRecord.java:1009)
      ... 76 more```
  </code></pre>