Skip to content

Add IHttpUpgradeFeature to TestServer for SignalR WebSocket support #33595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2021

Conversation

BrennanConroy
Copy link
Member

SignalR checks for IHttpWebSocketFeature which is set by the WebSocket middleware if the IHttpUpgradeFeature exists.

private static bool ServerHasWebSockets(IFeatureCollection features)
{
return features.Get<IHttpWebSocketFeature>() != null;
}

I don't know how much validation we need if any for saying that the request supports websockets. Also, currently throwing from IHttpUpgradeFeature.UpgradeAsync since TestServer doesn't use that for the stream.

Going to see if we can get this into preview6 since the new WebSocketFactory option was added to SignalR in preview5 with the intent to allow TestServer websockets to work with the client.

Copy link
Contributor

@shirhatti shirhatti left a comment

Choose a reason for hiding this comment

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

Thanks Brennan!

@@ -54,5 +55,48 @@ public async Task ConnectAsync_ShouldSetRequestProperties(string requestUri, str
Assert.Equal(expectedHost, capturedHost);
Assert.Equal("/connect", capturedPath);
}

[Fact]
public async Task CanAcceptWebSocket()
Copy link
Member

Choose a reason for hiding this comment

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

You want a different test for the normal TestServer scenario that shows the upgrade and WebSocket features are present, but an upgrade isn't possible.

@BrennanConroy
Copy link
Member Author

@Pilchie for preview6 consideration

});
})))
{
var client = testServer.CreateWebSocketClient();
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I meant that you'd send a non-websocket request here like you do in the signalr negotiation scenario. Including app.UseWebSockets(); in this test makes sense and the checking that it does add the IHttpWebSocketFeature SignalR needs.

@Pilchie
Copy link
Member

Pilchie commented Jun 17, 2021

Can you send tactics a mail for approval at this point? Since builds have been sent out to start validation, I don't want to reset them without approval.

@BrennanConroy
Copy link
Member Author

Since builds have been sent out to start validation, I don't want to reset them without approval.

Darn, I don't think it's worth resetting for this.

@Pilchie
Copy link
Member

Pilchie commented Jun 17, 2021

Actually, I might have confused Preview 6 with servicing builds, I don't think those are out, but most teams are mailing Tactics for approval.

@BrennanConroy
Copy link
Member Author

@dotnet/aspnet-build Tactics approved over email this morning, merge when convenient!

@dougbu dougbu merged commit 19876f0 into release/6.0-preview6 Jun 18, 2021
@dougbu dougbu deleted the brecon/testserver branch June 18, 2021 19:24
@BrennanConroy BrennanConroy added this to the 6.0-preview6 milestone Jun 18, 2021
BrennanConroy added a commit that referenced this pull request Jun 18, 2021
…33595)

* Add IHttpUpgradeFeature to TestServer for SignalR WebSocket support
* fb
* more test
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants