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.

SignalR does not work for .net core - react template

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kwstasarvacommented, 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.

1reaction
malimingcommented, Oct 22, 2019

@kwstasarva 💯 I will update the template.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET 6 with React won't connect to SignalR
I want to migrate my .NET Core 5 React project to .NET 6, but I'm facing some issues with SignalR. I've followed the...
Read more >
Creating a simple real-time chat with .NET Core, ReactJS ...
Now your API is correctly configured to use SignalR. Client. To start our client run the following command in the Chatty root folder:...
Read more >
SignalR Troubleshooting
Take a look at ASP.NET Core SignalR. This document describes common troubleshooting issues with SignalR. Software versions used in this topic.
Read more >
Using SignalR in ASP.NET Core & React to send messages
Firstly, we will integrate SignalR into our React app by running acommand line in the terminal in Visual Studio Code. Just make sure...
Read more >
Integrating SignalR with React TypeScript and ASP.NET Core
NET Core application. Run the following command prompt: yarn create react-app clientapp --template typescript.
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