File tree Expand file tree Collapse file tree 4 files changed +45
-15
lines changed Expand file tree Collapse file tree 4 files changed +45
-15
lines changed Original file line number Diff line number Diff line change 100
100
nil ))
101
101
(no-url req))))
102
102
103
+ (defn exception-handler [ctx ex response-stream]
104
+ (cond
105
+ ; ; could happens when io.netty.handler.codec.http.HttpObjectAggregator
106
+ ; ; is part of the pipeline
107
+ (instance? TooLongFrameException ex)
108
+ (s/put! response-stream ex)
109
+
110
+ ; ; when SSL handshake failed
111
+ (netty/ssl-handshake-error? ex)
112
+ (let [^Throwable handshake-error (.getCause ^Throwable ex)]
113
+ (s/put! response-stream handshake-error))
114
+
115
+ (not (instance? IOException ex))
116
+ (log/warn ex " error in HTTP client" )))
117
+
103
118
(defn raw-client-handler
104
119
[response-stream buffer-capacity]
105
120
(let [stream (atom nil )
117
132
118
133
:exception-caught
119
134
([_ ctx ex]
120
- (when-not (instance? IOException ex)
121
- (log/warn ex " error in HTTP client" )))
135
+ (exception-handler ctx ex response-stream))
122
136
123
137
:channel-inactive
124
138
([_ ctx]
169
183
170
184
:exception-caught
171
185
([_ ctx ex]
172
- (cond
173
- ; could happens when io.netty.handler.codec.http.HttpObjectAggregator
174
- ; is part of the pipeline
175
- (instance? TooLongFrameException ex)
176
- (s/put! response-stream ex)
177
-
178
- (not (instance? IOException ex))
179
- (log/warn ex " error in HTTP client" )))
186
+ (exception-handler ctx ex response-stream))
180
187
181
188
:channel-inactive
182
189
([_ ctx]
Original file line number Diff line number Diff line change 209
209
(invalid-value-response req rsp))))))))))))
210
210
211
211
(defn exception-handler [ctx ex]
212
- (when-not (instance? IOException ex)
212
+ (cond
213
+ ; ; do not need to log an entire stack trace when SSL handshake failed
214
+ (netty/ssl-handshake-error? ex)
215
+ (log/warn " SSL handshake failure:"
216
+ (.getMessage ^Throwable (.getCause ^Throwable ex)))
217
+
218
+ (not (instance? IOException ex))
213
219
(log/warn ex " error in HTTP server" )))
214
220
215
221
(defn invalid-request? [^HttpRequest req]
Original file line number Diff line number Diff line change 37
37
SslContext
38
38
SslContextBuilder
39
39
SslHandler]
40
+ [io.netty.handler.codec DecoderException]
40
41
[io.netty.handler.ssl.util
41
42
SelfSignedCertificate InsecureTrustManagerFactory]
42
43
[io.netty.resolver
76
77
LoggingHandler
77
78
LogLevel]
78
79
[java.security.cert X509Certificate]
79
- [java.security PrivateKey]))
80
+ [java.security PrivateKey]
81
+ [javax.net.ssl SSLHandshakeException]))
80
82
81
83
; ;;
82
84
789
791
^SslHandler (.get SslHandler)
790
792
.engine
791
793
.getSession))
794
+
795
+ (defn ssl-handshake-error? [^Throwable ex]
796
+ (and (instance? DecoderException ex)
797
+ (instance? SSLHandshakeException (.getCause ex))))
798
+
792
799
; ;;
793
800
794
801
(defprotocol AlephServer
Original file line number Diff line number Diff line change 42
42
43
43
:exception-caught
44
44
([_ ctx ex]
45
- (when-not (instance? IOException ex)
46
- (log/warn ex " error in TCP server" )))
45
+ (cond
46
+ ; ; do not need to log an entire stack trace when SSL handshake failed
47
+ (netty/ssl-handshake-error? ex)
48
+ (log/warn " SSL handshake failure:"
49
+ (.getMessage ^Throwable (.getCause ^Throwable ex)))
50
+
51
+ (not (instance? IOException ex))
52
+ (log/warn ex " error in TCP server" )))
47
53
48
54
:channel-inactive
49
55
([_ ctx]
115
121
:exception-caught
116
122
([_ ctx ex]
117
123
(when-not (d/error! d ex)
118
- (log/warn ex " error in TCP client" )))
124
+ (if (netty/ssl-handshake-error? ex)
125
+ ; ; do not need to log an entire stack trace when SSL handshake failed
126
+ (log/warn " SSL handshake failure:"
127
+ (.getMessage ^Throwable (.getCause ^Throwable ex)))
128
+ (log/warn ex " error in TCP client" ))))
119
129
120
130
:channel-inactive
121
131
([_ ctx]
You can’t perform that action at this time.
0 commit comments