[SPRING] http2 요청을하기 위해 Spring의 RestTemplate을 구성하는 방법은 무엇입니까?
SPRINGhttp2 요청을하기 위해 Spring의 RestTemplate을 구성하는 방법은 무엇입니까?
SpringClient (서버)에 GET Request를 호출하는 RestClient가 있고, 서버가 HTTP2 요청을 수락하고 302 응답을 얻고 있습니다. Spring RestTemplate을 사용하여 Http2 요청을 보내는 방법.
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://example.com/static/mobile/get-token": unexpected end of stream on Connection{domain.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}; nested exception is java.io.IOException: unexpected end of stream on Connection{example.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:732)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:680)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:600)
at com.domain.Sample.main(Sample.java:45)
Caused by: java.io.IOException: unexpected end of stream on Connection{example.com:443, proxy=DIRECT hostAddress=example.com cipherSuite=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 protocol=http/1.1}
at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:205)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.springframework.http.client.OkHttp3ClientHttpRequest.executeInternal(OkHttp3ClientHttpRequest.java:73)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:723)
... 3 more
해결법
-
==============================
1.OkHttp3ClientHttpRequestFactory를 사용하십시오.
OkHttp3ClientHttpRequestFactory를 사용하십시오.
RestTemplate http2Template = new RestTemplate(new OkHttp3ClientHttpRequestFactory());
from https://stackoverflow.com/questions/52222992/how-to-configure-springs-resttemplate-to-make-http2-requests by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 원래 수신 스레드 외부에서 HttpSession에 액세스 (0) | 2019.05.12 |
---|---|
[SPRING] 봄 MVC 게시물 요청 (0) | 2019.05.12 |
[SPRING] 최대 절전 모드 자바 10 (0) | 2019.05.12 |
[SPRING] 봄 + 최대 절전 모드 : 테이블에서 레코드를 삭제할 수 없습니다. (0) | 2019.05.12 |
[SPRING] 봄 mvc : 외부 폴더에 대한 리소스 액세스 (0) | 2019.05.12 |