https://bz.apache.org/bugzilla/show_bug.cgi?id=57762

            Bug ID: 57762
           Summary: WebSocket client doesn't detect forceful connection
                    failures
           Product: Tomcat 8
           Version: 8.0.20
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: WebSocket
          Assignee: dev@tomcat.apache.org
          Reporter: palmer...@gmail.com

It appears that the WebSocket client can't detect when a connection is
forcefully closed. Given the following example program:

public class App2 {
    @ClientEndpoint
    public static class Client {
        @OnClose
        public void onClose() {
            System.out.println("CLOSED");
        }

        @OnError
        public void onError(Throwable t) {
            System.out.println("ERROR: " + t);
        }
    }

    public static void main(final String[] args) throws Exception {
        final WebSocketContainer container =
ContainerProvider.getWebSocketContainer();
        System.out.println("Container: " + container);
        container.connectToServer(
                Client.class,
                URI.create("ws://echo.websocket.org/"));
        Thread.sleep(Long.MAX_VALUE);
    }
}

I then modified /etc/hosts so that echo.websocket.org resolved to localhost. I
then set up an SSH tunnel to direct local port 80 to echo.websocket.org (which
is 174.129.224.73):

sudo ssh me@someserver -L 80:174.129.224.73:80

I then started the program. It connected. Next, I killed the SSH session.
Neither the onClosed on onError methods were invoked.

When I tested the same program running on Tyrus 1.10, however, onClose was
invoked with a CloseReason 10006 - Closed Abnormally.

I think the Tyrus behavior is correct - the socket is dead and the program
should be notified.

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

Reply via email to