@ aspnet / signalr无法用于生产

时间:2019-02-06 10:29:20

标签: node.js angular web-applications signalr

我创建了一个无信号的azure无服务器功能api,并在angular组件中进行了访问。安装程序在开发环境中运行良好,但是在生产环境中却失败了。是否有人对此有任何信息或在SignalR中遇到过此类问题。

signalr.service.ts

import { HubConnection,HubConnectionBuilder } from '@aspnet/signalr';
import * as signalR from '@aspnet/signalr';

export class SignalRService {

  private readonly _baseUrl: string = "https://xxxx.azurewebsites.net/api/";
  private hubConnection: HubConnection;

  constructor(private http: Http) {  }

  // Get connection string from signlar 
  private getConnectionInfo(): Observable<SignalRConnectionInfo> {

       let requestUrl = `${this._baseUrl}negotiate`;
       return this.http.get(requestUrl)
            .map(res => res.json());
   }

  // Initialize
  init() {
     console.log(`initializing SignalRService...`);
      this.getConnectionInfo().subscribe(info => {
         // console.log(`received info for endpoint ${info.accessToken}`);

          let options = {
                accessTokenFactory: () => info.accessToken
             };

             this.hubConnection = new HubConnectionBuilder()
                 .withUrl(info.url, options)
                .configureLogging(signalR.LogLevel.Information)
                .build();

            this.hubConnection.start().catch(err => 
            console.error(err.toString()));

           this.hubConnection.on('notify', (data: any) => {
                console.log(data)
         });

       });
   }

}

以下是错误消息:

> SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\ws\lib\websocket.js:11:27)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10) ***/


0 个答案:

没有答案