Skip to content

WebSockets integration tests failing in 3.0 #16841

Closed
@benmccallum

Description

@benmccallum

Describe the bug

I'm trying to upgrade the GraphQL server project to support netcoreapp3.0 but stuck with integration tests failing for 3.0 only (e.g. they work for netfx and netcoreapp2.2).

To Reproduce

  1. Clone code for PR here: Support ASP.NET Core 3.0 graphql-dotnet/server#280
  2. Run tests under Transports.Subscriptions.WebSockets.Tests (netcoreapp3.0)
  3. See failures for the two tests in WebSocketConnectionFacts
  Message: 
    System.InvalidOperationException : Incomplete handshake, status code: 404
  Stack Trace: 
    WebSocketClient.ConnectAsync(Uri uri, CancellationToken cancellationToken)
    WebSocketsConnectionFacts.Should_accept_websocket_connection() line 62
    --- End of stack trace from previous location where exception was thrown ---

The functionality actually works at runtime. If you:

  1. Run the Samples.Server project (on netcoreapp3.0)
  2. Browser to /ui/playground
  3. Enter the following as a query to start the ws subscription and run it.
subscription {
  messageAdded {
    from {
      displayName
    }
    content
  }
}
  1. Open another tab in the playground ui, enter the following and run it a few times.
mutation{
  addMessage(message: {
    content: "some content",
    fromId: "123",
    sentAt: "2019-11-01"
  }) {
    sentAt
  }
}
  1. Go back to the subscription tab and see that the messages have come through outta the ws.

The fact that it's a 404 made me think of the routing changes in 3.0, but I've been unable to find anything specific to a custom WebSockets middleware and as demonstrated above it works when run properly.

So it must be something to do with the TestHost or the way we are configuring it and the TestServer. See GraphQL.Server.Transports.WebSockets.Tests.WebSocketsConnectionFacts's constructor. I've followed @Tratcher's advice for the new call pattern when using the TestServer directly (rather than via the factory abstraction), using a custom TestStartup setting AllowSynchronousIO to true (as we're still on Newtonsoft.Json internally until we can make the shift).

The only other thing I can say is that it doesn't seem like the middleware as setup by the TestStartup ever gets run, nor does any services I'd expect to see appear to be on the _server instance's resolved services.

So I'm close, but just not sure what I'm doing wrong or if I've found a bug. Any help would be greatly appreciated.

Further technical details

  • ASP.NET Core version: 3.0
  • Include the output of dotnet --info
PS C:\Users\Developer> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.1.802 [C:\Program Files\dotnet\sdk]
  2.2.101 [C:\Program Files\dotnet\sdk]
  2.2.402 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version: VS 2019 v16.3.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions