Expand my Community achievements bar.

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

Avatar

Level 4

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-cod....

 

But this is still showing the same error. 

 

Best regards,

Vijaya Kumar Arumugam

10 Replies

Avatar

Level 6

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

Avatar

Level 4

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

Avatar

Community Advisor

Hi @vjleo94 ,

Hope you may have given some default integer value for connectionTimeout in config class if not you may try.

Or it might that scan is not that intelligent to go to 2-3 level then you may need to directly set the timeout.

Thanks

Avatar

Level 4

Hi @MukeshYadav_ ,

The values are set in config. The later seems to be the case. It only seems to scan the first level.This results in redundant code as I have to add in each class.

Avatar

Community Advisor

Hi @vjleo94 ,

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

MukeshYadav__0-1729867363902.png

Thanks

Avatar

Level 8

Hi @vjleo94 

 

Try adding

.setConnectionRequestTimeout(httpServiceConfiguration.connectionTimeout())

Avatar

Level 4

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.

 

Avatar

Administrator

@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

Avatar

Level 4

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