Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

SignalR connection not working sometime on client Side. #7360


User avatar
0
huntethan89 created

Hi,

I am using SignalR in ASPNET ZERO (v 5.0.0.0). I have a new controller which is not ABP controller. And implemented SIgnalR on that. It is working fine but sometimes it breaks and stop displaying message on client side. i am showing code below what i have done.
Code on cshtml page:-
                                <script type="text/javascript">
                                abp.signalr = abp.signalr || {};
                                abp.signalr.autoConnect = false;
                            </script>
                            <script src="~/Scripts/jquery.signalR-2.4.0.js"></script>
                            <script src="~/signalr/hubs"></script>
                            <script src="~/Abp/Framework/scripts/libs/abp.signalr.js"></script>
                                    
code on partial view for SignalR requests : -
                        <script type="text/javascript">
                                $(document).ready(function () {
                                    $.connection.hub.start();
                                    abp.signalr.connect();
                                     var chatHub = $.connection.myHub;
                                     
                                      $(document).on('click', '#PreviewLeftSideClick', function () {
                                                chatHub.server.paceModeSlideClick('test data');                           
                                      });
                                     chatHub.client.paceModeSlideClick = function (data) {
                                     alert(data);
                                      };
                                });
                          </script>  
                          
code on cs file :-
                         public class MyHub : Hub, ITransientDependency
                        {
                                    public void PaceModeSlideClick(string data)
                            {
                                    Clients.All.paceModeSlideClick(string.Format("{0}",data);
                            }

                        }
                        

I am attaching images to show what i got when checking connection on console.

a) 1.png - It fetched all the hubs. So, when clicking on server side, client is getting proper messages.

1.png

b) 2.png - It fetched only one hub (abpcommonhub), when clicking on server side, there is no effect on client side.

** 2.png**

We are getting this error sometime. Its only one page. Sometime on refreshing the page we are getting 1.png image message and sometimes 2.png image message. Please suggest what to do.

Thanks


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    SignalR can disconnect, that is normal but it should reconnect in that case. This problem was fixed in https://github.com/aspnetboilerplate/aspnetboilerplate/pull/4314. If you upgrade ABP nuget packages in your project, the problem must be solved. You can only apply the changes in the PR if you want.

  • User Avatar
    0
    huntethan89 created

    Hi,

    Shall I update all ABP dlls in web project or any particular dll?
    

    Thanks

  • User Avatar
    0
    huntethan89 created

    The PR is showing changes in file '/Abp/Framework/scripts/libs/abp.signalr-client.js'. But this file is not present in v5.0.

    Thanks

  • User Avatar
    0
    maliming created
    Support Team

    @smartlayer Can you share your project code to [email protected]?