Skip to content

Commit 21db6af

Browse files
committed
Fix RequestToActiveConnectionIdKillsPreviousConnectionLongPolling
1 parent d168ea7 commit 21db6af

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/SignalR/common/Http.Connections/src/Internal/HttpConnectionDispatcher.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,6 @@ private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connecti
223223

224224
try
225225
{
226-
var pollAgain = true;
227-
228226
// If the application ended before the transport task then we potentially need to end the connection
229227
if (resultTask == connection.ApplicationTask)
230228
{
@@ -243,9 +241,11 @@ private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connecti
243241
// We should be able to safely dispose because there's no more data being written
244242
// We don't need to wait for close here since we've already waited for both sides
245243
await _manager.DisposeAndRemoveAsync(connection, closeGracefully: false);
246-
247-
// Don't poll again if we've removed the connection completely
248-
pollAgain = false;
244+
}
245+
else
246+
{
247+
// Only allow repoll if we aren't removing the connection.
248+
connection.MarkInactive();
249249
}
250250
}
251251
else if (resultTask.IsFaulted)
@@ -255,17 +255,10 @@ private async Task ExecuteAsync(HttpContext context, ConnectionDelegate connecti
255255

256256
// transport task was faulted, we should remove the connection
257257
await _manager.DisposeAndRemoveAsync(connection, closeGracefully: false);
258-
259-
pollAgain = false;
260-
}
261-
else if (context.Response.StatusCode == StatusCodes.Status204NoContent)
262-
{
263-
// Don't poll if the transport task was canceled
264-
pollAgain = false;
265258
}
266-
267-
if (pollAgain)
259+
else
268260
{
261+
// Only allow repoll if we aren't removing the connection.
269262
connection.MarkInactive();
270263
}
271264
}

src/SignalR/common/Http.Connections/src/Internal/Transports/LongPollingTransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task ProcessRequestAsync(HttpContext context, CancellationToken tok
6060
{
6161
// 3 cases:
6262
// 1 - Request aborted, the client disconnected (no response)
63-
// 2 - The poll timeout is hit (204)
63+
// 2 - The poll timeout is hit (200)
6464
// 3 - A new request comes in and cancels this request (204)
6565

6666
// Case 1

0 commit comments

Comments
 (0)