In Spring boot running in ECS getting connection reset - using restTemplate - spring-boot

I deployed the spring boot in AWS ECS
When making api using restetemplate ,it is giving the below error
org.springframework.web.client.ResourceAccessException: I/O error on POST request for "THE URL": Connection reset; nested exception is java.net.SocketException: Connection reset
But this error is occurring intermediate only , how to resolve this issue

Related

Connection Timeout for Spring Redis using Redis Cloud

I am trying to connect Redis in my Spring application.
I have created a Redis Database in Redis Cloudredis-10228.c15.us-east-1-2.ec2.cloud.redislabs.com:10228.
I have configured the following in my application.properties
spring.redis.host=redis-10228.c15.us-east-1-2.ec2.cloud.redislabs.com:10228
spring.redis.password=<password-from-redis-cloud>
I am still getting Redis Connection failure event after providing password.
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to redis-10228.c15.us-east-1-2.ec2.cloud.redislabs.com:10228
Caused by: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to redis-10228.c15.us-east-1-2.ec2.cloud.redislabs.com:10228
Any misconfiguration done from my part?
You need to specify the redis port in a different property:
spring.redis.host=redis-10228.c15.us-east-1-2.ec2.cloud.redislabs.com
spring.redis.port=10228
See this for more details.

Handle Tomcat aborting file upload in Spring Boot

Is there a way to handle case when Tomcat aborts file upload due to defined limits, in order to return decent response (for example 413 Payload Too Large)?
I'm using Spring Boot 2.4.0 with following configuration:
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=20MB
spring.servlet.multipart.max-request-size=21MB
server.tomcat.max-swallow-size=21MB
server.tomcat.max-http-form-post-size=20MB
When trying to upload files larger than 21MB (or 26MB for some reason) using REST API, I receive java.net.SocketException: Connection reset by peer because Tomcat aborts the upload (closes the socket), due to defined maxSwallowSize. There's no exception in the logs by Spring. When running tests, I can see that RestTemplate retries couple of times, but eventually throws exception.
You can find MWE on GitHub.

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.

ZUUL Forwarding Error when invoking the service

I have a EUREKA , ZUUL and a sample ATOMIC Service deployed to WAS Liberty Profile.
When I try to hit the proxy url for ATOMIC Service I get Forwarding error.
com.netflix.zuul.exception.ZuulException: Forwarding error
at org.springframework.cloud.netflix.zuul.filters.route.RibbonRoutingFilter.forward (RibbonRoutingFilter.java:145)
Caused by: java.lang.RuntimeException: SRV.8.2: RequestWrapper objects must extend ServletRequestWrapper or HttpServletRequestWrapper
at com.ibm.wsspi.webcontainer.util.ServletUtil.unwrapRequest(ServletUtil.java:91)
at com.ibm.wsspi.webcontainer.util.ServletUtil.unwrapRequest(ServletUtil.java:63)
The complete stack trace is at,
https://github.com/bsridhar123/ZUUL/blob/master/logs/PROXY_ATOMIC.txt
I have shared the code for these services in the github repos.
--For ZUUL Reverse Proxy Service
https://github.com/bsridhar123/ZUUL
Can someone please help me on this.

Axis2 Web Services Client in IBM Websphere throws "Error in key derivation" exception

We have a secure web service client(rampart) deployed in IBM websphere. We are facing a scenario where the service provider (external) may go down frequently. Our client works fine and can access the service till it goes down. Once the provider comes back after a downtime, the client throws an exception :
org.apache.axis2.AxisFault: General security error; nested exception is:
org.apache.ws.security.conversation.ConversationException: Error in key derivation
To recover from this currently we need a server restart, which is unacceptable. Has anybody had a similar issue? Any pointer would be a great help.
Thanks in advance,
Ros

Resources