Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Conversation

davidfowl
Copy link
Member

  • 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

#500

Copy link
Contributor

@analogrelay analogrelay left a 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");
Copy link
Contributor

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.

Copy link
Member Author

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);
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use StatusCodes.Status204NoContent?

@davidfowl
Copy link
Member Author

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());
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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)
Copy link
Contributor

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)
{
Copy link
Contributor

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.");
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert?

Copy link
Member Author

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));
Copy link
Contributor

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.

Copy link
Member Author

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.

davidfowl added 6 commits June 7, 2017 23:16
- 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
@davidfowl davidfowl force-pushed the davidfowl/timeout-longpolling branch from 283932f to a036848 Compare June 8, 2017 06:37
@davidfowl davidfowl merged commit 523517f into dev Jun 8, 2017
@davidfowl davidfowl deleted the davidfowl/timeout-longpolling branch June 9, 2017 18:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants