Repository navigation
Commit a74c398
authored
okhttp: Set socket read timeout during TLS handshake (#13081)
In `OkHttpClientTransport`, direct TLS connection setup calls
`OkHttpTlsUpgrader.upgrade(...)` without configuring a socket read
timeout (`setSoTimeout`). When a middlebox or unresponsive server
completes the TCP three-way handshake and acknowledges the TLS
`ClientHello` without sending a `ServerHello` or `RST`,
`sslSocket.startHandshake()` blocks indefinitely in socket read. Because
`this.socket` and `asyncSink` are only assigned after
`OkHttpTlsUpgrader.upgrade(...)` returns, channel shutdown cannot close
the underlying socket either, leaving the subchannel permanently stuck
in `CONNECTING`. Configure `sock.setSoTimeout(proxySocketTimeout)`
before `OkHttpTlsUpgrader.upgrade(...)` and reset it to `0` once the TLS
upgrade completes, matching the timeout handling in
`createHttpProxySocket`. Also close `sock` via
`GrpcUtil.closeQuietly(sock)` in `catch (Exception e)` so the socket is
not leaked when handshake setup fails before
`asyncSink.becomeConnected(...)` takes ownership.1 parent 1084e97 commit a74c398
2 files changed
Lines changed: 36 additions & 0 deletions
File tree
- okhttp/src
- main/java/io/grpc/okhttp
- test/java/io/grpc/okhttp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
| 742 | + | |
742 | 743 | | |
743 | 744 | | |
744 | 745 | | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
745 | 749 | | |
746 | 750 | | |
747 | 751 | | |
| |||
761 | 765 | | |
762 | 766 | | |
763 | 767 | | |
| 768 | + | |
764 | 769 | | |
765 | 770 | | |
766 | 771 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
2099 | 2101 | | |
2100 | 2102 | | |
2101 | 2103 | | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
2102 | 2133 | | |
2103 | 2134 | | |
2104 | 2135 | | |
| |||
0 commit comments