tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [tomcat] branch master updated: Log additional information when a WebSocket connection fails
Date Wed, 08 Jul 2020 20:43:39 GMT
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new c46bbc3  Log additional information when a WebSocket connection fails
c46bbc3 is described below

commit c46bbc3a9320aa25dc5e5cd3d124f596e57b4370
Author: Mark Thomas <markt@apache.org>
AuthorDate: Wed Jul 8 21:42:42 2020 +0100

    Log additional information when a WebSocket connection fails
    
    This is primarily to help debug a relatively rare CI failure in
    TestWebSocketFrameClient.testConnectToRootEndpoint()
---
 java/org/apache/tomcat/websocket/LocalStrings.properties   |  1 +
 java/org/apache/tomcat/websocket/WsWebSocketContainer.java | 12 ++++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/tomcat/websocket/LocalStrings.properties b/java/org/apache/tomcat/websocket/LocalStrings.properties
index 929822d..8c3c505 100644
--- a/java/org/apache/tomcat/websocket/LocalStrings.properties
+++ b/java/org/apache/tomcat/websocket/LocalStrings.properties
@@ -142,6 +142,7 @@ wsWebSocketContainer.pathNoHost=No host was specified in URI
 wsWebSocketContainer.pathWrongScheme=The scheme [{0}] is not supported. The supported schemes
are ws and wss
 wsWebSocketContainer.proxyConnectFail=Failed to connect to the configured Proxy [{0}]. The
HTTP response code was [{1}]
 wsWebSocketContainer.redirectThreshold=Cyclic Location header [{0}] detected / reached max
number of redirects [{1}] of max [{2}]
+wsWebSocketContainer.responseFail=The HTTP upgrade to WebSocket failed but partial data may
have been received: Status Code [{0}], HTTP headers [{1}]
 wsWebSocketContainer.sessionCloseFail=Session with ID [{0}] did not close cleanly
 wsWebSocketContainer.sslEngineFail=Unable to create SSLEngine to support SSL/TLS connections
 wsWebSocketContainer.unsupportedAuthScheme=Failed to handle HTTP response code [{0}]. Unsupported
Authentication scheme [{1}] returned in response
diff --git a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
index dbe4c12..c78da3c 100644
--- a/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
+++ b/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
@@ -801,9 +801,17 @@ public class WsWebSocketContainer implements WebSocketContainer, BackgroundProce
             response.clear();
             // Blocking read
             Future<Integer> read = channel.read(response);
-            Integer bytesRead = read.get(timeout, TimeUnit.MILLISECONDS);
+            Integer bytesRead;
+            try {
+                bytesRead = read.get(timeout, TimeUnit.MILLISECONDS);
+            } catch (TimeoutException e) {
+                TimeoutException te = new TimeoutException(
+                        sm.getString("wsWebSocketContainer.responseFail", Integer.toString(status),
headers));
+                te.initCause(e);
+                throw te;
+            }
             if (bytesRead.intValue() == -1) {
-                throw new EOFException();
+                throw new EOFException(sm.getString("wsWebSocketContainer.responseFail",
Integer.toString(status), headers));
             }
             response.flip();
             while (response.hasRemaining() && !readHeaders) {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message