Should I worry the debug exception in the signalR integration test?

0

The exception is printed in the debug window, something like this:

vstest.executionengine.x86.exe Error: 0 : Error while closing the websocket: System.Net.WebSockets.WebSocketException (0x80004005): An internal WebSocket error occurred. Please see the innerException, if present, for more details. ---> System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host at System.Net.WebSockets.WebSocketConnectionStream.WebSocketConnection.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)

There are more, I just cut them.

What I am trying to do is writing integration test for my SignalR server and client.

Here are 2 simple test cases:

        [TestMethod]
        public void It_Should_Allow_Register()
        {
            using (var server = WebApp.Start<Startup>("http://+:61744"))
            {
                var client = GetConnectedClient();
                Assert.IsTrue(client.IsConnected);
                DisposeClients(client);
            }
        }

        [TestMethod]
        public void It_Should_Allow_MultipleClients()
        {
            using (var server = WebApp.Start<Startup>("http://+:61744"))
            {
                var client1 = GetConnectedClient();
                Assert.IsTrue(client1.IsConnected);

                var client2 = GetConnectedClient();
                Assert.IsTrue(client2.IsConnected);

                DisposeClients(client1, client2);
            }
        }

I have other test cases, but the idea is, every test will bring up the in-memory self-hosted Owin server, and create one or more clients connecting to it, and then safely disconnect all the clients after the business logic is executed.

Unfortunately, if I run one test case at a time, it works fine. But if I run all of them together, that annoying WebSocketException is printed.

The test case appears to be executed fine. I print out the request and response (when invoking SignalR server function) in debug. Everything is fine exception the exception in the debug trace.

I found this post: SignalR Websocket Exception when closing client

so for no reason, I added

Connection.Stop(TimeSpan.FromSeconds(3000)); 

Connection is a HubConnection.

It's still the same.

Honestly, should I even care, if I am sure all business logic in my tests are executed?

c#
signalr
integration-testing
asked on Stack Overflow Dec 18, 2018 by sowen

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0