Skip to content

Commit cd536dc

Browse files
committed
Fix SignalR + SPA through Envoy
1 parent a9fc1e2 commit cd536dc

4 files changed

Lines changed: 54 additions & 76 deletions

File tree

src/Web/WebSPA/Client/modules/shared/services/signalr.service.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Injectable } from '@angular/core';
22
import { SecurityService } from './security.service';
33
import { ConfigurationService } from './configuration.service';
4-
import { HubConnection, HubConnectionBuilder, LogLevel, HttpTransportType } from '@aspnet/signalr';
4+
import { HubConnection, HubConnectionBuilder, LogLevel, HttpTransportType } from '@microsoft/signalr';
55
import { ToastrService } from 'ngx-toastr';
66
import { Subject } from 'rxjs';
77

@@ -25,7 +25,7 @@ export class SignalrService {
2525
this.SignalrHubUrl = this.configurationService.serverSettings.signalrHubUrl;
2626
this.init();
2727
});
28-
}
28+
}
2929
}
3030

3131
public stop() {
@@ -36,16 +36,18 @@ export class SignalrService {
3636
if (this.securityService.IsAuthorized == true) {
3737
this.register();
3838
this.stablishConnection();
39-
this.registerHandlers();
40-
}
39+
this.registerHandlers();
40+
}
4141
}
4242

4343
private register() {
4444
this._hubConnection = new HubConnectionBuilder()
4545
.withUrl(this.SignalrHubUrl + '/hub/notificationhub', {
46+
transport: HttpTransportType.LongPolling,
4647
accessTokenFactory: () => this.securityService.GetToken()
4748
})
4849
.configureLogging(LogLevel.Information)
50+
.withAutomaticReconnect()
4951
.build();
5052
}
5153

@@ -61,6 +63,7 @@ export class SignalrService {
6163

6264
private registerHandlers() {
6365
this._hubConnection.on('UpdatedOrderState', (msg) => {
66+
console.log(`Order ${msg.orderId} updated to ${msg.status}`);
6467
this.toastr.success('Updated to status: ' + msg.status, 'Order Id: ' + msg.orderId);
6568
this.msgSignalrSource.next();
6669
});

0 commit comments

Comments
 (0)