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)
-
0
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.
-
0
Hi,
Shall I update all ABP dlls in web project or any particular dll?
Thanks
-
0
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
-
0
@smartlayer Can you share your project code to [email protected]?