Home > Blockchain >  SignalR not connecting after updating to dotNet6
SignalR not connecting after updating to dotNet6

Time:11-29

I updated server to .NET 6 and kept old program and startup classes without change and everything is working fine but SignalR. Since the update, xamarin client refuses to connect to hub, it stays in Connecting state.

Do i have to make any change to signalR on server side or is the problem somewhere else?

Namespace Hubs
{
    public class NotifyHub: Hub
    {

        public override async Task OnConnectedAsync()
        {
            await base.OnConnectedAsync();
        }
    }

xamarin client:

namespace Clients
{
    class NotifyHubClient : INotifyHubClient
    {
        IDocumentService _ds;
        private HubConnection hubConnection;

        public async Task Connect()
        {
            if (hubConnection == null || hubConnection.State 
                == HubConnectionState.Disconnected)
            {
                InitConnection();
                await hubConnection.StartAsync();
            }
        }

        private void InitConnection()
        {
            _ds = ContainerLocator.Container.Resolve<IDocumentService>();
            hubConnection = new HubConnectionBuilder()
              .WithUrl("https://10.0.0.189:9001/hobosoft/notifier", options => {
                  options.HttpMessageHandlerFactory = (message) =>
                  {
                       if (message is HttpClientHandler clientHandler)
                           clientHandler.ServerCertificateCustomValidationCallback
                             =(sender, certificate, chain, sslPolicyErrors) 
                            => { return true; };
                       return message;
                  };
              })
             .WithAutomaticReconnect()
             .Build();
        }

CodePudding user response:

So I found where the problem is. VS2022 have problem with xamarin SignalR, getting back to VS2019 solved the issue.

So that means I am unable update server to .NET 6, yet...

  • Related