Native WebSocket connection remains open when its target page has expired
维护者通常 1 天内回复
@reiern70 已经在做这个了。
开始于 2026年11月13日。
评估
这个 Issue 还没有评估数据。
描述
Description
When a client opens a native WebSocket for a page id that the session's page manager can no longer find, AbstractWebSocketProcessor accepts the handshake, registers the connection, and then does nothing. No behavior's onConnect runs, the connection is not closed, and the only trace is a debug log line. The client sees an open socket that never receives anything.
This can occur when the HTTP/Wicket session survives an application restart or redeployment but the page store does not. Existing browser pages reconnect using their previous page IDs. If those pages cannot be restored, the connections remain open without reaching their behaviors. Page-store eviction can produce the same condition without a restart.
Where
AbstractWebSocketProcessor.broadcastMessage(IWebSocketMessage, IWebSocketConnection, boolean, long), 10.12.0 and 11.0.0 around line 328:
IPageManager pageManager = session.getPageManager();
Page page = getPage(pageManager);
if (page != null)
{
// ... broadcast to the page's behaviors
}
else
{
LOG.debug("Page with id '{}' has been expired. No message will be broadcast!", pageId);
}
For the ConnectedMessage broadcast from onConnect, the connection stays in the registry and open. Later client frames and pushes take the same branch, so nothing reaches a behavior and the client gets no answer.
The null check was added by WICKET-6267, to stop a push to an expired page from throwing in WebSocketRequestHandler's constructor. That fixed the exception but left the connection open.
The neighboring cases already close the connection: since 10.12 a missing session closes with POLICY_VIOLATION_ERROR_CODE and SESSION_ENDED ("Session ended"), and a refused WebSocketResource closes with NOT_AUTHORIZED ("Not authorized"). A missing page is the one outcome of that lookup that leaves the connection open and unusable.
Effect on clients
A client cannot tell this apart from a slow server. A client that waits for a first message from the server (a hello, an initial state push) times out, closes, reconnects with the same page id, and gets the same silent connection, until its retry budget runs out. Reloading the page fixes it at once, but nothing tells the client or the user to do that.
Steps to reproduce
- Render a stateful page with a
WebSocketBehaviorwhoseonConnectsends a text message. - Connect its socket and see the message arrive.
- Clear the page store, keeping the session alive.
- Close the socket and reconnect using the original socket URL (same
pageIdparameter). - The handshake succeeds,
onConnectis never called, no message arrives, and the connection stays open and registered. The server logs only, at debug: "Page with id 'N' has been expired. No message will be broadcast!"
No external session store or restart is needed.
Proposed change
Close for ConnectedMessage, client text/binary messages, and pushes. Do not initiate another close for ClosedMessage, ErrorMessage, or AbortedMessage. As in the session-ended branch, remove the registry entry in every case:
static final String PAGE_EXPIRED = "Page expired";
...
else
{
connectionRegistry.removeConnection(application, sessionId, connection.getKey());
LOG.debug("Page with id '{}' has expired. No message will be broadcast!", pageId);
if (isSpecialMessage(message) == false)
{
connection.close(WebSocketConnectionOriginFilter.POLICY_VIOLATION_ERROR_CODE,
PAGE_EXPIRED);
}
}
1008 with "Page expired" fits alongside Wicket's existing closes. What matters is that the distinction is documented and stable, so clients can depend on it: a client handles "this page is gone, reload it" very differently from "the session is no longer available". It can then react to a definite close instead of a timeout, for example by telling the user that the page is out of date.
- 主要语言
- Java
- 星标
- 800
- 派生
- 437
- 平均合并
- 21 小时 36 分钟
- 30 天内合并 PR
- 167
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/wicket 的其他 Issue
-
PropertyResolver fails on JDK classes with a non-public field named like the property可能已有人在做 @vaibhavgupta443 今天认领。 未关闭good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
Stop the autocomplete from accumulating request parameters while typing可能已有人在做 @aryankalantri 今天认领。 未关闭good first issue
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
Validate the report-uri value given to CSPHeaderConfiguration#reportBack可能已有人在做 @AzizOuertani 于 3 天前认领。 未关闭good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 70/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
jenkinsci/user-guide-ai-chatbot-plugin#132 ·
维护者通常 6 天内回复
-
account assessment course feature lecture
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
bug db/dameng user-priority/P2
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
app:learninggoalhub enhancement good first issue
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100