5

i use okhttp to send request to server but i got the error

Server chose TLSv1, but that protocol version is not enabled or not supported by the client.
javax.net.ssl.SSLHandshakeException: Server chose TLSv1, but that protocol version is not enabled or not supported by the client.
    at sun.security.ssl.ClientHandshaker.serverHello(ClientHandshaker.java:452)
    at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:206)
    at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
    at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
    at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:336)
    at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:300)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:185)
    at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
    at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
    at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
    at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:169)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)

But i send request more time, it works. I don't know why. Please help me!

user207421
  • 305,947
  • 44
  • 307
  • 483
Tuhalang
  • 91
  • 1
  • 1
  • 6

2 Answers2

1

OkHttp remembers which routes have failed previously and tries other routes instead when making new connections. It's possible your server is reachable via multiple routes.

Typically this is due to multiple IP addresses, but it could also be due to multiple client-side proxies.

If different routes have different TLS settings that could cause this behavior.

Jesse Wilson
  • 39,078
  • 8
  • 121
  • 128
  • oh i think be due to multiple client-side proxies. But you can suggest me how to log router is used in okhttp? – Tuhalang Jan 15 '20 at 04:51
0

Check your Java versions, if they were updated recently or there is a mismatch between servers, the error will show as this.

Run these to check the culprit:

sudo java -version

//to check for updates
sudo yum history list
sudo yum history info ID_SUSPECTED_ON_LIST

Just wanted to post another answer I didn't see mentioned that turned out to be the problem on my system.

Petro
  • 3,484
  • 3
  • 32
  • 59