-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When calling window.print() from the client while connected to a SignalR hub, the SignalR connection closes unexpectedly.
It seems that window.print() freezes the browser UI thread, which prevents the client heartbeat/ping from being processed. As a result, SignalR considers the client unresponsive and closes the connection.
Environment:
- ASP.NET Core (SignalR)
- SignalR JavaScript client (browser)
- Browser: Chrome/Edge (latest)
Expected Behavior
Expected Behavior:
- The SignalR connection should remain stable during/after the print dialog is open.
- Heartbeats should ideally tolerate temporary UI thread blocking.
Actual Behavior:
- While the print dialog is open, no pings are sent.
- After the ClientTimeoutInterval elapses, the connection closes with error:
Steps To Reproduce
Steps to Reproduce:
-
Start a simple SignalR hub with default options:
services.AddSignalR(options =>
{
options.EnableDetailedErrors = true;
options.HandshakeTimeout = TimeSpan.FromSeconds(60);
options.KeepAliveInterval = TimeSpan.FromSeconds(15);
options.ClientTimeoutInterval = TimeSpan.FromSeconds(50);
}); -
Connect a JavaScript client in the browser.
-
While connected, trigger a window.print() call.
setTimeout(() => {
window.print();
}, 0);
4.Observe network traffic and logs.
Exceptions (if any)
Connection closed with an error.
OperationCanceledException: Client hasn't sent a message/ping within the configured ClientTimeoutInterval.
Log
"type":7,"error":"Connection closed with an error. OperationCanceledException: Client hasn't sent a message/ping within the configured ClientTimeoutInterval.","allowReconnect":true
.NET Version
8
Anything else?
