SignalR does not work for .net core - react template
See original GitHub issueI 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:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
@kwstasarva 💯 I will update the template.