Skip to content

Comments

Add httpProtocol method to WebServiceClient.Builder#591

Closed
ggabora wants to merge 1 commit intomaxmind:mainfrom
ggabora:Branch_main_httpProtocol_method_in_WebClientService.Builder
Closed

Add httpProtocol method to WebServiceClient.Builder#591
ggabora wants to merge 1 commit intomaxmind:mainfrom
ggabora:Branch_main_httpProtocol_method_in_WebClientService.Builder

Conversation

@ggabora
Copy link

@ggabora ggabora commented Aug 21, 2025

  • Added httpVersion() method on WebServiceClient.Builder
    which allows configuring HTTP protocol version (HTTP/1.1 or HTTP/2) for web
    service requests.
  • Updated README.md with comprehensive HTTP protocol configuration documentation.
  • Added detailed information about HTTP version settings, proxy configuration,
    timeout settings, authentication, and connection management.
  • Improved documentation for developers using the web service client.

@horgh
Copy link
Contributor

horgh commented Aug 21, 2025

Hi! Thanks for the PR.

Could you tell me about the use case for this option? I think generally HTTP/1.1 should be discouraged, e.g. https://http1mustdie.com/, so I'm not sure about adding something new to enable it.

@ggabora
Copy link
Author

ggabora commented Aug 22, 2025

@horgh Hi, we have a case when we get connection reset on the WebServiceClient connections because of network/firewall inbetween our app and maxmind. In other cases where we use HttpClient with http/1.1 we set the jdk keepalive timeout to a lower value than the one of the network/firewall so that the connections in the pool are 'evicted' sooner. In case of http/2 there is no such option so the simplest solution for us would be to downgrade to http/1.1.
A better approach would be to somehow be able to have access to the http/2 connections of the WebServiceClient and 'evict' them when needed or implement a resilience mechanism inside WebServiceClient to handle connection reset cases and recreate the connection.
Another solution would be to create a WebServiceClient per request but event that is a bit hard since there is no close() logic like it was in previous versions.

Thanks!

@ggabora
Copy link
Author

ggabora commented Aug 22, 2025

Btw, maybe an increase in the minor version is more appropriate for this change?

@horgh
Copy link
Contributor

horgh commented Aug 22, 2025

Thanks for the background!

It looks like there is a similar setting to the one you mentioned for HTTP/1.1 that applies for HTTP/2 connections: jdk.httpclient.keepalive.timeout.h2. The docs say that it falls back to using jdk.httpclient.keepalive.timeout if it's not set. Would using this setting work for you?

@ggabora
Copy link
Author

ggabora commented Aug 23, 2025

It would work if we could use Java 20 where this change was introduced https://bugs.openjdk.org/browse/JDK-8295649
Currently we are using java 17. I'll check what it would take to migrate to java 20 or higher and get back.
Thanks!

@ggabora
Copy link
Author

ggabora commented Aug 25, 2025

Morning, migrating to java 20+ is not possible in the near future, so we're stuck with this fix.

@horgh
Copy link
Contributor

horgh commented Aug 25, 2025

I see. To that end, I've added a method to the builder called httpClient() which would let you pass in an HttpClient configured as you need it. I think that'd be more of an API we'd want to support, rather than having something specific to HTTP/1.1 See #592.

@ggabora
Copy link
Author

ggabora commented Aug 26, 2025

Great, thank you! When is the next release scheduled?

@ggabora
Copy link
Author

ggabora commented Aug 26, 2025

Not needed anymore because it is solved by #592

@ggabora ggabora closed this Aug 26, 2025
@ggabora ggabora deleted the Branch_main_httpProtocol_method_in_WebClientService.Builder branch August 26, 2025 06:47
@horgh
Copy link
Contributor

horgh commented Aug 26, 2025

I think we should be able to release in the next day or two!

@horgh
Copy link
Contributor

horgh commented Aug 28, 2025

We released 4.4.0 with this! https://central.sonatype.com/artifact/com.maxmind.geoip2/geoip2

@ggabora
Copy link
Author

ggabora commented Aug 29, 2025

Great, thank you again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants