Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SignalR does not work for .net core - react template #4899

Closed
cokceken opened this issue Oct 3, 2019 · 6 comments · Fixed by aspnetboilerplate/module-zero-core-template#476

Comments

@cokceken
Copy link

cokceken commented Oct 3, 2019

I am using Abp.AspNetCode 4.9.0 with react template. Under App.tsx there is a signalR initialization code piece

if (!!this.props.sessionStore!.currentLogin.user && 
    this.props.sessionStore!.currentLogin.application.features['SignalR']) {
if (this.props.sessionStore!.currentLogin.application.features['SignalR.AspNetCore']) {
    SignalRAspNetCoreHelper.initSignalR();
}

So I provided "SignalR" and "SignalR.AspNetCore" features to the related login. And when the code gets executed I am seeing following error from the file signalRAspNetCoreHelper.ts

Util.loadScript(AppConsts.appBaseUrl + '/dist/abp.signalr-client.js');

dist/abp.signalr-client.js:1 - Uncaught SyntaxError: Unexpected token '<'

That's because script loading from /dist/abp.signalr-client.js returns a regular 404 page.

Also when I load abp.signalr-client.js as a class manually, the signalR variable is undefined so the code does not work.

Could you help me with bringing SignalR up for the react template?

@ismcagdas
Copy link
Member

@cokceken thank you for reporting this problem, we will check and fix it.

@ismcagdas ismcagdas added this to the v5.0 milestone Oct 8, 2019
@kwstasarva
Copy link

kwstasarva commented Oct 11, 2019

@cokceken Hi,

The issue is cause from the SignalRAspNetCoreHelper.ts line 18.

Util.loadScript(AppConsts.appBaseUrl + '/dist/abp.signalr-client.js');

The code tries to load a file from localhost:3000/dist/abp.signalr-client.js and fails to do so.
The reason behind it is because, such URL does not exist.

In order to fix the issue for the development environment you should modify the craco.config.js in line 44 and include the following piece of code
to:'dist/abp.signalr-client.js'

Please find my full craco.config.js file below for reference.

craco.config.js.zip

Haven't tested my change in the production environment but I am pretty sure that you should follow the same approach.

After making that change, the error should now be gone. Enjoy.

@cokceken
Copy link
Author

@kwstasarva It worked! Thank you :)

@ismcagdas ismcagdas modified the milestones: v5.0, v5.1 Oct 14, 2019
@kwstasarva
Copy link

@cokceken Glad I've helped :)

@maliming maliming self-assigned this Oct 22, 2019
@maliming
Copy link
Member

@kwstasarva 💯 I will update the template.

@kwstasarva
Copy link

@maliming Thank you for the awesome work! Glad I've helped!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants