-
Notifications
You must be signed in to change notification settings - Fork 446
Add support for timing out poll requests #538
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix you grammar.
{ | ||
_logger.LogDebug("The server is closing the connection"); | ||
|
||
// Transport closed or polling stopped, we're done | ||
break; | ||
} | ||
else if (response.StatusCode == HttpStatusCode.NoContent) | ||
{ | ||
_logger.LogDebug("The server is timed out poll"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also do good grammar. It best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL
_logger.LogDebug("Connection {connectionId} is already active via {requestId}. Cancelling previous request.", connection.ConnectionId, connection.GetHttpContext().TraceIdentifier); | ||
var existing = connection.GetHttpContext(); | ||
|
||
_logger.LogDebug("Connection {connectionId} is already active via {requestId}. Cancelling previous request.", connection.ConnectionId, existing.TraceIdentifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cancelling
... I don't know if I should just give up on this
@@ -0,0 +1,11 @@ | |||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright
|
||
Assert.True(channel.Out.TryComplete()); | ||
|
||
await poll.ProcessRequestAsync(context, context.RequestAborted); | ||
|
||
Assert.Equal(204, context.Response.StatusCode); | ||
Assert.Equal(205, context.Response.StatusCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use StatusCodes.Status205ResetContent
?
{ | ||
await poll.ProcessRequestAsync(context, cts.Token).OrTimeout(); | ||
|
||
Assert.Equal(204, context.Response.StatusCode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use StatusCodes.Status204NoContent
?
HttpClient is trolling me and I'm trying to figure out why. |
@@ -697,6 +723,7 @@ public class HttpConnectionDispatcherTests | |||
var connection = manager.CreateConnection(); | |||
var dispatcher = new HttpConnectionDispatcher(manager, new LoggerFactory()); | |||
var context = new DefaultHttpContext(); | |||
context.Features.Set<IHttpResponseFeature>(new ResponseFeature()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I started to use RegisterForDispose and the DefaultHttpContext
throws. I plan to fix this in HttpAbstractions because it's a troll.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - it's clear now. I did not know it threw by default.
@@ -210,7 +210,7 @@ public HttpConnectionDispatcher(ConnectionManager manager, ILoggerFactory logger | |||
await connection.TransportTask; | |||
|
|||
// If the status code is a 205 it means the connection is done | |||
if (context.Response.StatusCode == StatusCodes.Status205ResetContent) | |||
if (context.Response.StatusCode == StatusCodes.Status204NoContent) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the warning above
@@ -219,7 +219,7 @@ public HttpConnectionDispatcher(ConnectionManager manager, ILoggerFactory logger | |||
pollAgain = false; | |||
} | |||
} | |||
else if (context.Response.StatusCode == StatusCodes.Status205ResetContent) | |||
else if (context.Response.StatusCode == StatusCodes.Status204NoContent) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this branch dead now?
@@ -74,14 +74,16 @@ public LongPollingTransport(CancellationToken timeoutToken, ReadableChannel<byte | |||
// Case 2 | |||
else if (_timeoutToken.IsCancellationRequested) | |||
{ | |||
_logger.LogInformation("Poll request timed out. Sending 204 response."); | |||
context.Response.StatusCode = StatusCodes.Status204NoContent; | |||
_logger.LogInformation("Poll request timed out. Sending 200 response."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the comment above still mentioning 205
@@ -95,7 +96,7 @@ public void Scan() | |||
|
|||
try | |||
{ | |||
if (_disposed) | |||
if (_disposed || Debugger.IsAttached) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, we're keeping it this time.
@@ -18,7 +20,7 @@ public static Task OrTimeout(this Task task, int milliseconds = DefaultTimeout, | |||
|
|||
public static async Task OrTimeout(this Task task, TimeSpan timeout, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int? lineNumber = null) | |||
{ | |||
var completed = await Task.WhenAny(task, Task.Delay(timeout)); | |||
var completed = await Task.WhenAny(task, Task.Delay(Debugger.IsAttached ? Timeout.InfiniteTimeSpan : timeout)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember how much you were against it - but this is so useful when debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I gave up. We're keeping it. Our product is impossible to debug without it.
- Default poll request is 110 seconds (like in previous versions of SignalR) - Changed the "stop polling" status code to 205 and the time out status code to 204 - Added LongPollingOptions to HttpSocketOptions
- Added support for not timing out while debugging
283932f
to
a036848
Compare
status code to 204
#500