title: Websocket closed with status code: 1011 - ASP.NET CORE with Angular 10
body: <h1><strong>Here is the log (console browser)</strong></h1>
  <pre><code>[2020-11-26T11:40:56.352Z] Debug: Selecting transport 'WebSockets'.
  Utils.js:228 [2020-11-26T11:40:56.353Z] Trace: (WebSockets transport) Connecting.
  Utils.js:224 [2020-11-26T11:40:56.402Z] Information: WebSocket connected to ws://localhost:8080/upload-process?id=14Cj6nHlbbp1RJX6GnO0fA.
  Utils.js:228 [2020-11-26T11:40:56.403Z] Debug: The HttpConnection connected successfully.
  Utils.js:228 [2020-11-26T11:40:56.403Z] Debug: Sending handshake request.
  Utils.js:228 [2020-11-26T11:40:56.404Z] Trace: (WebSockets transport) sending data. String data of length 39.
  Utils.js:224 [2020-11-26T11:40:56.405Z] Information: Using HubProtocol 'messagepack'.
  Utils.js:228 [2020-11-26T11:40:56.469Z] Trace: (WebSockets transport) socket closed.
  Utils.js:228 [2020-11-26T11:40:56.469Z] Debug: HttpConnection.stopConnection(Error: WebSocket closed with status code: 1011 ().) called while in state Connected.
  Utils.js:218 [2020-11-26T11:40:56.469Z] Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1011 ().'.
  push../node_modules/@microsoft/signalr/dist/esm/Utils.js.ConsoleLogger.log @ Utils.js:218
  Utils.js:228 [2020-11-26T11:40:56.470Z] Debug: HubConnection.connectionClosed(Error: WebSocket closed with status code: 1011 ().) called while in state Connecting.
  Utils.js:228 [2020-11-26T11:40:56.470Z] Debug: Hub handshake failed with error 'Error: WebSocket closed with status code: 1011 ().' during start(). Stopping HubConnection.
  Utils.js:228 [2020-11-26T11:40:56.471Z] Debug: Call to HttpConnection.stop(Error: WebSocket closed with status code: 1011 ().) ignored because the connection is already in the disconnected state.
  Utils.js:228 [2020-11-26T11:40:56.471Z] Debug: HubConnection failed to start successfully because of error 'Error: WebSocket closed with status code: 1011 ().'.
  
  </code></pre>
  <p><em>obs: I have the same log on JavaScript (PoC).</em></p>
  <h1><strong>Angular 10</strong></h1>
  <p>packages: &quot;@microsoft/signalr&quot;: &quot;^5.0.0&quot;,
  &quot;@microsoft/signalr-protocol-msgpack&quot;: &quot;^5.0.0&quot;,</p>
  <pre><code>export class SignalRService extends BaseService {
    private hubConnection: HubConnection;
    private signalrUrl = `${this.environment.apiUpload}upload-process`;
    constructor() {
      super();
  
    }
  
    public connect = () =&gt; {
      this.startConnection();
      this.addListeners();
    }
  
    private getConnection(): HubConnection {
      return new HubConnectionBuilder()
        .withUrl(this.signalrUrl)
        .withHubProtocol(new MessagePackHubProtocol())
        .configureLogging(LogLevel.Trace)
        .build();
    }
  
    private startConnection(): any {
      this.hubConnection = this.getConnection();
  
      this.hubConnection.start()
        .then(() =&gt; console.log('connection started'))
        .catch((err) =&gt; console.log('error while establishing signalr connection: ' + err))
    }
  
    private addListeners(): any {
      this.hubConnection.on('ProcessUpload', (data: any) =&gt; {
        console.log('message received from API Controller ProcessUpload');
        console.log(data);
      });
  
    }
  }
  </code></pre>
  <h1><strong>API(backend)</strong></h1>
  <ul>
  <li><p>TargetFramework: netcoreapp3.1</p>
  </li>
  <li><p>Microsoft.AspNetCore.SignalR&quot; Version=&quot;1.1.0&quot;</p>
  </li>
  <li><p>Microsoft.AspNetCore.SignalR.Protocols.MessagePack&quot; Version=&quot;5.0.0&quot;</p>
  </li>
  </ul>
  <p><strong>Startup.cs</strong></p>
  <p>ConfigureServices</p>
  <pre><code>services.AddCors(options =&gt; options.AddPolicy(&quot;CorsPolicy&quot;,
              builder =&gt;
              {
                  builder.AllowAnyHeader()
                         .AllowAnyMethod()
                         .WithOrigins(&quot;http://localhost:4200&quot;)
                         .SetIsOriginAllowed((host) =&gt; true)
                         .AllowCredentials();
              }));
  </code></pre>
  <p>Configure</p>
  <pre><code>app.UseCors (option =&gt; option.AllowAnyOrigin ().AllowAnyMethod ().AllowAnyHeader ().WithOrigins(&quot;http://localhost:4200&quot;).AllowCredentials());
  
  app.UseEndpoints (endpoints =&gt; {
                  endpoints.MapControllers ();
                  endpoints.MapHub&lt;UploadProcessHub&gt;(&quot;/upload-process&quot;);
              });
  
  </code></pre>