reiern70 opened a new pull request, #1900:
URL: https://github.com/apache/wicket/pull/1900

   Closes #1899
   
   When a client opens a native WebSocket for a page id that the page manager 
of its session can no longer find, 
`AbstractWebSocketProcessor#broadcastMessage` accepted the handshake, 
registered the connection and then did nothing: no `onConnect`, no close, only 
a debug log line. Every later frame and push took the same branch. The client 
sat on an open socket that never received anything, and the registry kept a 
connection nobody could use.
   
   It happens whenever the session outlives its page store: a restart or 
redeployment with a persistent session store, or plain page store eviction, 
followed by the browser reconnecting with the page id it was rendered with.
   
   The null check came from WICKET-6267, which stopped a push to an expired 
page from throwing but left the connection open. The other outcomes of the same 
lookup already close: an ended session with 1008 `Session ended`, a refused 
`WebSocketResource` with 1008 `Not authorized`.
   
   ### What it does now
   
   - A missing page is handled like an ended session. The connection is removed 
from the registry and closed with 1008 (policy violation) and the reason `Page 
expired`.
   - A `ClosedMessage`, `ErrorMessage` or `AbortedMessage` for a missing page 
does not trigger a second close, but the connection is still removed from the 
registry.
   - The `broadcastMessage` javadoc and the native WebSockets chapter of the 
user guide document both reasons, `Session ended` and `Page expired`, so 
clients can rely on telling them apart.
   
   ### What applications see
   
   A client whose page has expired gets a close frame instead of a silent 
connection. Wicket's own script publishes it on `/websocket/closed` with the 
code and the reason, so an application can react to it, for example by offering 
a reload. No behavior of a missing page was reached before and none is reached 
now, so server-side code sees no difference. No API change, nothing to migrate.
   
   ### Not in this PR
   
   - An exception thrown while a message is processed is still only logged by 
the `catch` in `broadcastMessage`, and the connection stays open. Nothing in 
the issue shows that path, so it is left alone here.
   
   ### Backport
   
   To `wicket-11.x` in a backport PR (linked once open) and to `wicket-10.x` in 
another (linked once open), both clean cherry-picks.
   
   ### Tests
   
   - New `WebSocketPageExpiredTest` (wicket-native-websocket-tester): a 
connection to an expired page is closed at the handshake without `onConnect`. A 
live connection is closed by the first client message or push after its page 
expired, without reaching the behavior. A closing connection to an expired page 
is not closed again but leaves the registry. A live page keeps working. Against 
the unfixed processor, the three close tests fail.
   - `mvn clean verify -Pjs-test` is green.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to