question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling function 'SignalRModule', function calls are not supported.

See original GitHub issue

I’m using the Angular-cli to make a very basic “Hello world” app with SignalR using your module, and I keep getting this:

ERROR in Error encountered resolving symbol values statically. Calling function 'SignalRModule', function calls are not supported. Consider replacing the function
or lambda with a reference to an exported function, resolving symbol AppModule in C:/code/Ang2SR/src/app/app.module.ts, resolving symbol AppModule in C:/code/Ang2S
R/src/app/app.module.ts
webpack: Failed to compile.

My app.module:


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { EchoComponent } from './echo/echo.component';
import { signalrConfiguration } from './app.config';
import { SignalRModule, SignalRConnection, ConnectionStatus, BroadcastEventListener } from 'ng2-signalr';

@NgModule({
  declarations: [
    AppComponent,
    EchoComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    SignalRModule.configure(signalrConfiguration)
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.config.ts:


import { SignalRConfiguration } from 'ng2-signalr';

const signalrConfig = new SignalRConfiguration();
signalrConfig.hubName = 'echoHub';
signalrConfig.qs = { user: 'Hannes' };
signalrConfig.url = 'http://localhost:44369/signalr/hubs';


export const signalrConfiguration = signalrConfig;

Has this got something to do with publishing metadata/AoT? Any ideas?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:37 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
HNeukermanscommented, Mar 29, 2017

issue fixed in v2.0.0

2reactions
DaveMonagcommented, Mar 1, 2017

Ok, as none of the temporary fixes seemed to work for me, in order to build I’ve done the following in order to get things working. I absolutely do not suggest this fix, but if you just desperately need it to work, this does. Essentially I’ve entirely bypassed using the “SignalRModule” from ng2-signalr entirely, and just gone around it and that fixes the problem.

First off I cloned the repo from here rather than used “npm install ng2-signalr” as I needed the typescript. Then I moved that module into my app work space for ease of use.

in your app.module.ts, remove SignalRModule.configure(configuration) from your imports, and in providers, add

  providers: [
    SignalR,
    SignalRConfiguration
  ],

and at the top import them from the new module directory. E.g.:

import { SignalRConfiguration } from './modules/ng2-signalr';
import { SignalR } from './modules/ng2-signalr';

At this point you might want to move everything out of “lib” so that everything is just under ng2-signalr as opposed to “ng2-signalr/src”. Then in the new module, go into the signalr.ts and replace the constructor to this and add these three methods:

    public constructor(configuration: SignalRConfiguration, zone: NgZone) {

        this._configuration = configuration;
        this._zone = zone;
        this._jHubConnectionFn = this.getJConnectionFn();
    }

    private getJConnectionFn(): any {
        let jQuery = this.getJquery();
        let hubConnectionFn = (<any>window).jQuery.hubConnection;
        if (hubConnectionFn == null) throw new Error('Signalr failed to initialize. Script \'jquery.signalR.js\' is missing. Please make sure to include \'jquery.signalR.js\' script.');
        return hubConnectionFn;
    }

    private getJquery(): any {
        let jQuery = (<any>window).jQuery;
        if (jQuery == null) throw new Error('Signalr failed to initialize. Script \'jquery.js\' is missing. Please make sure to include jquery script.');
        return jQuery;
    }

    public configure(configuration: SignalRConfiguration) {
        this._configuration = configuration;

    }

Now I’ve put my config in a file called “app.config.ts”, which you can still use in this scenario:

import { SignalRConfiguration } from './modules/ng2-signalr';

export const signalrConfiguration = new SignalRConfiguration();

signalrConfiguration.hubName = 'yourHub';
signalrConfiguration.qs = { user: 'user' };
signalrConfiguration.url = 'http://whateveryourbackendis.azurewebsites.net';

I’ve been handling all the SignalR interactions in my app inside a service. In this service, in the constructor, I’ve added a call to the “configure” method we just added in _signalR:

  constructor(private _signalR: SignalR) {
    this._signalR.configure(signalrConfiguration);
    this._OnReceiveMessage = new BroadcastEventListener<Alarm>("message");
    this.setup();
  }

So obviously the problem for us lies with the SignalRModule, as just bypassing it all together and leaving everything else fine allows everything to work just fine. This obviously isn’t a permanent fix, but perhaps you can make something of this @HNeukermans .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function calls are not supported in decorators but ...
trying to setup ngx-formly-material-file, but I got an error: Function calls are not supported in decorators but 'FileTypeModule' was called.
Read more >
Develop & configure Azure Functions app - Azure SignalR
Details on how to develop and configure serverless real-time applications using Azure Functions and Azure SignalR Service.
Read more >
signalr_netcore | Flutter Package - Pub.dev
A flutter client for ASP.NET Core SignalR. The client is able to invoke server side hub functions and to receive method invocations issued...
Read more >
NET Core with SignalR and Angular – Real-Time Charts
It is important to call the UseCors method before the UseAuthorization method. That is it regarding the configuration. Let's move on to the...
Read more >
Build Real-time Applications with ASP.NET Core SignalR
Web apps are expected not only to function properly, but they need to do so with a ... NET has a popular real-time...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found