HTTP requests should always have socket and connect timeouts - Not fixed | Community
Skip to main content
vjleo94
Level 3
October 25, 2024

HTTP requests should always have socket and connect timeouts - Not fixed

  • October 25, 2024
  • 3 replies
  • 1884 views

Hi,

 

We have lot of critical issues with regarding "HTTP requests should always have socket and connect timeouts".

 

For this, I created one common configuration to set time outs in project level and use the same request config across all the clients. 

 

Lets say I call my service "httpService". So below is my code

 

httpClient = httpClientBuilderFactory.newBuilder().setDefaultRequestConfig(httpService.getRequestConfig()).build();

 

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-manager/content/using/custom-code-quality-rules.

 

But this is still showing the same error. 

 

Best regards,

Vijaya Kumar Arumugam

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

anupampat
Community Advisor
Community Advisor
October 25, 2024

Hi @vjleo94 ,

 

The snippet you have shared does not include the timeout configuration. Can you share that code as well.

Also, when you see the critical error it should also point to the class that it comes from, are you using the timeout configs correctly there ?

 

Regards,

Anupam Patra

vjleo94
vjleo94Author
Level 3
October 25, 2024

Hi @anupampat ,

In the snippet you can see 

httpService.getRequestConfig()

In that service method (httpService is my custom service), I am setting the timeouts

@Override
public RequestConfig getRequestConfig() {
return RequestConfig.custom()
.setConnectTimeout(httpServiceConfiguration.connectionTimeout())
.setSocketTimeout(httpServiceConfiguration.socketTimeout()).build();
}

Best regards,

Vijaya Kumar Arumugam

vjleo94
vjleo94Author
Level 3
October 25, 2024

Hi @vjleo94 ,

did you tried scanning after adding default values like this in config class?

Thanks


Yes, has always been there. So, still doesn't work.

 

Tethich
Community Advisor
Community Advisor
October 25, 2024

Hi @vjleo94 

 

Try adding

.setConnectionRequestTimeout(httpServiceConfiguration.connectionTimeout())
vjleo94
vjleo94Author
Level 3
October 25, 2024

Hi @tethich ,

Don't think its expecting request timeout, as I just tested there is no error for the class where I have created rthe same request config in the class itself.

 

kautuk_sahni
Community Manager
Community Manager
November 5, 2024

@vjleo94 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
vjleo94
vjleo94Author
Level 3
November 6, 2024

Hi @kautuk_sahni ,

There is no clean solution I found for this now.

Just for the build to be successful, I have added the method to set timeouts in each java class instead of using it from service. 

 

Best regards,

Vijaya Kumar A