Replies: 1 comment 3 replies
-
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
SignalR code is given below. Its consistently sending notifications to the client all the time. However after deploying it in Windows Server 2012 SP2 with load balanced, sticky session enabled servers, its not always sending the notifications to the caller consistently. Its works sometimes, fails most of the time.
Not sure what's going wrong. Any help is much appreciated. I have enabled client side trace, and attached the log with this ticket.
Thanks,
Mohan
SignalRService.ts
import { Injectable, EventEmitter } from '@angular/core';
import { HubConnection, HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
import { APP_CONFIG } from '@app/shared/Services/app-config.service';
import { AuthService } from '@app/core/auth.service';
const DEFAULT_TIMEOUT_IN_MS: number = 120 * 1000;
const DEFAULT_PING_INTERVAL_IN_MS: number = 45 * 1000;
@Injectable({
providedIn: 'root',
})
export class SignalrService {
private hubConnection: HubConnection | undefined;
public Notification: EventEmitter;
constructor(private readonly authService: AuthService) {
this.Notification = new EventEmitter();
}
public initialize(): Promise {
return new Promise((resolve, reject) => {
this.stopConnection();
const token = this.authService.accessToken;
}
stopConnection() {
if (this.hubConnection) {
this.hubConnection.stop();
this.hubConnection = null;
}
}
}
Client Consumer in ngOnInit():
this.signalrService.Notification.subscribe((result: string) => {
const parsedResult = JSON.parse(result);
if (parsedResult !== null) {
Server Hub Code:
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
namespace MyWeb.WebAPI.Hubs
{
[Authorize]
public class NotificationHub : Hub
{
public void SendNotification()
{
// Method intentionally left empty.
// Currently its used to start commnucation from Client to make sure SignalR Hud connection is fine
}
}
Controller:
_hub.Clients.All.GetNotification(JsonConvert.SerializeObject(response));
Beta Was this translation helpful? Give feedback.
All reactions