Hi,
We are trying to set up SignalR for our project. When we trigger the message from the server side, client does not receive the first message but it receives the second. It does not receive the third, either. And it receives the fourth, it goes like this. Trigger is in the IDistributedEventHandler implemented class.
This is the server side:
class ReportEventHandler: IDistributedEventHandler<ReportEto>{
private readonly IHubContext<NotificationHub> _hubContext;
public ReportEventHandler(IHubContext<NotificationHub> hubContext)
{
_hubContext = hubContext;
}
public async Task HandleEventAsync(ReportEto eventData)
{
await _hubContext.Clients.All.SendAsync("MessageReceived","Message");
}
}
This is the client side:
const connection = new signalR.HubConnectionBuilder()
.withUrl(environment.apis.default.url + '/signalr-hubs/notification')
.withAutomaticReconnect() .configureLogging(signalR.LogLevel.Information)
.build();
connection.on('MessageReceived', () => { this.toastNotificationService.queueToastNotification('info', 'New Message!', 'message'); });
connection.start().catch(err => console.log(err));
Our Hub.
using Volo.Abp.AspNetCore.SignalR;
namespace PCDMS.SignalR
{
public class NotificationHub : AbpHub
{
}
}
What could be the reason? Please help me understand and fix this. If we don't trigger signalr from event handler, it is working properly. If we add authorize keyword to hub, we can not receive any message.