Skip to content

[SignalR] HTTPS connection failed, and The server disconnected before the handshake could be started. #44181

@Wasenshi123

Description

@Wasenshi123

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I used SignalR .Net Client (6.0) to connect to my signalr hub on ASP NET Core server (3.1),

At first I got SSL error The SSL connection could not be established... : RemoteCertificateNameMismatch, so I bypass the validation at client side with:

.WithUrl("https://myurlxx/checkin", (opts) =>
{
    opts.HttpMessageHandlerFactory = (message) =>
    {
        if (message is HttpClientHandler clientHandler)
            // always verify the SSL certificate
            clientHandler.ServerCertificateCustomValidationCallback +=
                (sender, certificate, chain, sslPolicyErrors) => { return true; };
        return message;
    };
})

But then I got this instead:
** The server disconnected before the handshake could be started. **

I'm not sure how to fix this.

Expected Behavior

The connection should start successfully.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0 (client), 3.1 (server)

Anything else?

My server is running inside linux docker container and is behind Cloudflare. And no, I'm not using IIS.

here is my server log:

21:49:53.994 HTTP POST /checkin/negotiate?negotiateVersion=1 responded 200 
Response Body: {"negotiateVersion":1,"connectionId":"iIqcejTv7GjKuIkCN4_PIQ","connectionToken":"AgievSj2lGfUOW9q3ZYqsw","availableTransports":[{"transport":"WebSockets","transferFormats":["Text","Binary"]},{"transport":"ServerSentEvents","transferFormats":["Text"]},{"transport":"LongPolling","transferFormats":["Text","Binary"]}]}

21:49:55.244 HTTP POST /checkin/negotiate?negotiateVersion=1 responded 200
Response Body: {"negotiateVersion":1,"connectionId":"_ny6rLQUoXRC7sJhGRfPCA","connectionToken":"LroCos5HFSbs3fpX2_7ZIA","availableTransports":[{"transport":"WebSockets","transferFormats":["Text","Binary"]},{"transport":"ServerSentEvents","transferFormats":["Text"]},{"transport":"LongPolling","transferFormats":["Text","Binary"]}]}

21:50:11.851 HTTP GET /checkin?id=LroCos5HFSbs3fpX2_7ZIA responded 200
Response Body:
:
data: {"error":"Handshake was canceled."}�

Update: when I test with local url (https) on local dev debug server, I also get the same error. (http is working fine)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions