-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I am trying to support websockets with signalR 6 on Android, with a Xamarin app, my code works as intended with longpolling, but there are clear benefits for me in using websockets, and I now have tried for a long time to make this work. But if I set supported transports to Websockets only in the client I get the error message that Longpolling is dissabled in the client, but the server does provide Longpolling,
Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (LongPolling failed: The transport is disabled by the client.)
My client, does look like this;
this._connection = new HubConnectionBuilder()
.WithUrl($"{_host}/rabbitHub?deviceId={id}", (opts) =>
{
opts.HttpMessageHandlerFactory = (x) => new HttpClientHandler
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
};
opts.AccessTokenProvider = () => Task.FromResult(authToken ?? "bypassauthplz");
opts.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets /*| Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents | Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling*/;
} )
.WithAutomaticReconnect()
.ConfigureLogging(logging =>
{
logging.SetMinimumLevel(LogLevel.Trace);
}).Build();
and the Server is configured like this:
services.AddSignalR().AddHubOptions<RabbitHub>(options => { options.MaximumParallelInvocationsPerClient = 32; options.KeepAliveInterval = new TimeSpan(0,0,0,5); options.ClientTimeoutInterval = new TimeSpan(0,0,0,10); });
endpoints.MapHub<RabbitHub>("/rabbitHub", options => { options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling | HttpTransportType.ServerSentEvents; });
Expected Behavior
The Expected behavior would be that the client would be aple to connect to the SignalR Server via websockets, this seems to be no Problem with Android, if I connect to an non signalR Websocket I with System.Net.WebSockets, everithing is working as intendet.
So there has to be a bug in the Aspnet.core lib.
I'am using this lib with netstandard 2.1 for the client and .net6 for the server, but changing the server from 5 to 6 did not change anything.
Steps To Reproduce
I would like to provide a simple example, I will provide one as soon as I , find the time to Build one.
Exceptions (if any)
Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (LongPolling failed: The transport is disabled by the client.)
.NET Version
6
Anything else?
No response