TomCools / dropwizard-websocket-jsr356-bundle

A Dropwizard bundle that enables the usage of the Java API for WebSocket Protocol (JSR 356).
Apache License 2.0
22 stars 14 forks source link

Server shutdown closes websockets with wrong close code #6

Open sergio91pt opened 7 years ago

sergio91pt commented 7 years ago

Shutting down dropwizard closes all websockets with close code 1000 NORMAL_CLOSURE, instead of the correct one 1001 GOING_AWAY.

This impacts robust-websocket, which won't trigger a reconnection in case of a server restart because the server initiated closure is marked as normal.

sergio91pt commented 7 years ago

WebSocketServerFactory#onStop does close all open sessions with StatusCode.SHUTDOWN, but the fact remains that dropwizard does not (double checked with wireshark).

I added a breakpoint to the close method in AbstractWebSocketConnection. After sending a TERM signal to dropwizard it triggered, but not due to WebSocketServerFactory...

Thread [dw-24] (Suspended (breakpoint at line 249 in AbstractWebSocketConnection))  
    WebSocketServerConnection(AbstractWebSocketConnection).close() line: 249    
    SelectorManager$ManagedSelector.closeNoExceptions(Closeable) line: 724  
    SelectorManager$ManagedSelector.access$1100(SelectorManager$ManagedSelector, Closeable) line: 407   
    SelectorManager$ManagedSelector$EndPointCloser.run() line: 1031 
    InstrumentedQueuedThreadPool(QueuedThreadPool).runJob(Runnable) line: 635   
    QueuedThreadPool$3.run() line: 555  
    Thread.run() line: 745  
TomCools commented 2 years ago

I had abandoned this project, but am reviving it for DW 4. Will be looking into this.

TomCools commented 1 year ago

Now that DW 4.0 is out, I'll be picking this up again.