question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Websocket closed with status code: 1011

See original GitHub issue

Abp version: 3.6.0 framework: .Net Core. I using Abp.AspNetCore.SignalR in .Net Framework and .Net Core. and it’s normal in 3.5.0. When I upgraded to 3.6.0, .Net Framework is ok, but there was an error under.Net Core. 20180509162135

Here is the log:

ERROR 2018-05-09 15:49:05,211 [51   ] oft.AspNetCore.Sockets.ConnectionManager - Failed disposing connection 9c12c921-445e-49c2-9079-c87c7807225f.
System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. ---> System.MissingMethodException: Method not found: 'Boolean System.Memory`1.TryGetArray(System.ArraySegment`1<!0> ByRef)'.
   at System.Net.WebSockets.ManagedWebSocketExtensions.ReadAsync(Stream stream, Memory`1 destination, CancellationToken cancellationToken)
   at System.Net.WebSockets.ManagedWebSocket.<EnsureBufferContainsAsync>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Net.WebSockets.ManagedWebSocket.<ReceiveAsyncPrivate>d__62`2.MoveNext()
   at System.Net.WebSockets.ManagedWebSocket.<ReceiveAsyncPrivate>d__62`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.Internal.Transports.WebSocketsTransport.<StartReceiving>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.Internal.Transports.WebSocketsTransport.<ProcessSocketAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.Internal.Transports.WebSocketsTransport.<ProcessRequestAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.DefaultConnectionContext.<WaitOnTasks>d__63.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.DefaultConnectionContext.<DisposeAsync>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Sockets.ConnectionManager.<DisposeAndRemoveAsync>d__15.MoveNext()

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

20reactions
neil-119commented, Jun 8, 2019

I just wanted to post here since it’s one of the first Google results to come up for this error. I spent the better part of a day trying to figure out the solution, so hope this helps someone. First, I was running ASP.NET Core 3.0. I had to upgrade to the latest preview version on NPM, and of course ensure that I was running the latest .NET Core 3.0 preview SDK. However, that didn’t solve my problems. After much searching, and the client-side SignalR logging showing no recourse, I found out that the SignalR library doesn’t actually show logs in the server-side console window during debugging unless explicitly told. Enable it in Program.cs:

public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    // <snipped> as not relevant
                })
                .ConfigureLogging(logging =>
                {
                    logging.AddFilter("Microsoft.AspNetCore.SignalR", LogLevel.Debug);
                    logging.AddFilter("Microsoft.AspNetCore.Http.Connections", LogLevel.Debug);
                });
    }

In my case, I found out that the Redis backplane that I had enabled was being blocked by the firewall, silently erroring out and closing the connection. After whitelisting my IP, all went well!

2reactions
Eddyhandersoncommented, Jan 10, 2021

I have added the logging configuration as @neil-119 said.

.ConfigureLogging(logging =>
                {
                    logging.AddFilter("Microsoft.AspNetCore.SignalR", LogLevel.Debug);
                    logging.AddFilter("Microsoft.AspNetCore.Http.Connections", LogLevel.Debug);
                });

And then, when i ran the app, i received the following message:

The type initializer for ‘Microsoft.AspNetCore.SignalR.Protocol.HandshakeProtocol’ threw an exception. —> System.IO.FileLoadException: Could not load file or assembly The located assembly’s manifest definition does not match the assembly reference of System.Text.Encodings.Web

This happen when you have two or more lib referencing the same lib with different version. When this happen, just one of the version will be choosen by runtime locates assembly. For better explaination search: https://medium.com/@RupaniChirag/how-to-resolve-could-not-load-file-or-assembly-or-one-of-its-dependencies-and-why-this-cf8d48d788eb

To resolve this i’ve simply to go to the nuget manager and install the lastest version of System.Text.Encodings.Web Therefore, this error can occur for diverse reason, my main advice is to set on the logging and then see the message on the terminal to fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Websocket closed with status code: 1011 - ASP.NET ...
stop(Error: WebSocket closed with status code: 1011 ().) ignored because the connection is already in the disconnected state. Utils.js:228 [2020 ...
Read more >
WebSocketCloseStatus Enum (System.Net.WebSockets)
(1011) The connection will be closed by the server because of an error on the server. InvalidMessageType, 1003. (1003) The client or server...
Read more >
GlobalEvent websocket closed with reason code as 1011
/** * "1011 indicates that a server is terminating the connection because it encountered * an unexpected condition that prevented it from ...
Read more >
WebSocket Status Codes Cheat Sheet
1011 indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request. 1012 ......
Read more >
Websocket close frame control
1011 indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found