You are using a version of the client that isn't compatible with the server. Client version 1.5, server version undefined

Ankit Singh 2 0 Reputation points
2024-05-13T12:36:08.4+00:00

1

I'm using SignalR in my project (asp.net and react js).

Here in C# I'm using (.net 4.8)

Microsoft.AspNet.SignalR.Client

  • Version - 1.2.2.0
  • Runtime version - v4.0.30319

Microsoft.AspNet.SignalR.Core

  • Version - 2.2.3.0
  • Runtime version - v4.0.30319

Microsoft.AspNet.SignalR.Owin

  • Version - 1.2.2.0
  • Runtime version - v4.0.30319

Microsoft.AspNet.SignalR.SystemWeb

  • Version - 2.2.3.0

In react I'm using these script in index.html

In jquerySignalR.js this is being used ASP.NET SignalR JavaScript Library v2.2.3

Getting this error:

I'm using SignalR in my project (asp.net and react js).

Here in C# I'm using (.net 4.8)

Microsoft.AspNet.SignalR.Client

  • Version - 1.2.2.0
  • Runtime version - v4.0.30319

Microsoft.AspNet.SignalR.Core

  • Version - 2.2.3.0
  • Runtime version - v4.0.30319

Microsoft.AspNet.SignalR.Owin

  • Version - 1.2.2.0
  • Runtime version - v4.0.30319

Microsoft.AspNet.SignalR.SystemWeb

  • Version - 2.2.3.0

In react I'm using these script in index.html

In jquerySignalR.js this is being used ASP.NET SignalR JavaScript Library v2.2.3

Getting this error:

You are using a version of the client that isn't compatible with the server. Client version 1.5, server version undefined

<script type="text/javascript" src="/assets/js/jquery-3.4.1.min.js"></script>
	<script type="text/javascript" src="/assets/js/jquerySignalR.js"></script>
code to connect signalR from frontend 

startHub(self) {
        if ($.connection && $.connection.hub && $.connection.userNotificationHub) {
            $.connection.hub.url = Util.url + 'signalr';
            $.connection.hub.logging = true;

            $.connection.userNotificationHub.client.onLogoutCustomMessage = self.onLogoutCustom;
            $.connection.hub.start().done(function (connection) {
                console.log('Service Started', connection.id);
            }).fail(function (a) {
                console.log('Could not Connect! simult' + a);
            });
        }
        else {
            setTimeout(function () { self.startHub(self) }, 500);
        }
    }


In the backend in startup.cs I have

using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Microsoft.Owin.Cors;
using Owin;
using System;

[assembly: OwinStartup(typeof(Volza.Startup))]
namespace Volza
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            GlobalHost.Configuration.DisconnectTimeout = TimeSpan.FromSeconds(3600);
            //app.UseCors(CorsOptions.AllowAll);
            //app.MapSignalR();
            // Any connection or hub wire up and configuration should go here
            app.Map("/signalr", map =>
            {
                // Setup the CORS middleware to run before SignalR.
                // By default this will allow all origins. You can 
                // configure the set of origins and/or http verbs by
                // providing a cors options with a different policy.
                //map.UseCors(CorsOptions.AllowAll);
                var hubConfiguration = new HubConfiguration
                {
                    // You can enable JSONP by uncommenting line below.
                    // JSONP requests are insecure but some older browsers (and some
                    // versions of IE) require JSONP to work cross domain
                    // EnableJSONP = true
                    EnableJavaScriptProxies = true,
                    EnableDetailedErrors = true

                };
                // Run the SignalR pipeline. We're not using MapSignalR
                // since this branch already runs under the "/signalr"
                // path.
                map.RunSignalR(hubConfiguration);
            });
        }
    }
}
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,319 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,394 questions
{count} votes