I have a spring cloud webflux application, I want my application to work on the http2 protocol.
I create a certificate and keys through Keystore explorer, add them to the configuration of my gateway and microservice:
server: ssl: key-store: classpath:ssl.pfx key-store-password: password keyStoreType: PKCS12 key-password: password enabled: true http2: enabled: true
I place the ssl.pfx file in resources, in gateway and in microservice.
But when I make a get request to my microservice through the gateway, I get an error:
2024-06-17T15:22:04.048+03:00 WARN 14896 --- [my-service] [tor-http-nio-10] .s.ApplicationProtocolNegotiationHandler : [id: 0x5853edda, L:/192.168.78.78:54840 - R:/192.168.78.78:56587] Failed to select the application-level protocol:io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record ....
error on the gateway:
reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: Error has been observed at the following site(s): *__checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ AuthorizationWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ExceptionTranslationWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ LogoutWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ServerRequestCacheWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ SecurityContextServerWebExchangeWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ AuthenticationWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ReactorContextWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ HttpHeaderWriterWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ ServerWebExchangeReactorContextWebFilter [DefaultWebFilterChain] *__checkpoint ⇢ org.springframework.security.web.server.WebFilterChainProxy [DefaultWebFilterChain]
When I make requests directly to the microservice, via https://.. it works, the h2 protocol is in the browser, but it doesn’t work through the gateway.
Accordingly, I have questions:
- What am I doing wrong?
- Is it actually possible to make a gateway http2?
There are not many examples, the cloud setting is nowhere to be found, I saw several articles about grpc, but I haven’t tried it yet, in theory you can only get by with h2.