Any SignalR module sample available? #2575
-
Hi, I am trying to incorporate SignalR in my modules (not for chat but to broadcast tournament updates) but I cannot find a way to put it in place without modifying the Oqtane server (which would make future upgrades difficult). Does anyone have a simple Oqtane module (even chat) with SignalR, MapHub, etc.? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 9 replies
-
Hi @wcrisafu
|
Beta Was this translation helpful? Give feedback.
-
I tried to use the "app.UseEndpoints(endpoints =>" (see below) and I received the error "Message=EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware and so must be added to the request execution pipeline before EndpointMiddleware. Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseRouting' inside the call to 'Configure(...)' in the application startup code." public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
Beta Was this translation helpful? Give feedback.
-
Huge step forward. Look like I was just missing the "app.UseRouting();" before the "app.UseEndpoints(" Now I just need to get the correct URL make this work and I should be in business: "hubConnection = new HubConnectionBuilder().WithUrl(url).Build();" |
Beta Was this translation helpful? Give feedback.
-
I have a sample that works all fine until you try to use [Authorize] on the Hub. private async Task GetJwtTokenAsync()
} private async Task InitializeHubConnection()
} I'm able to get token and send to Hub but always get 403. |
Beta Was this translation helpful? Give feedback.
-
This should work
options.Headers.Add("Authorization", "Bearer " + accessToken);
})
.Build();
Work,?
|
Beta Was this translation helpful? Give feedback.
-
We are on single tenant! Irrespective of token passed in query or header, we stay on 403. We are using Oqtane admin and a normal user, both are in role registered as well. How can I debug? Since we get 403, we are failing on authorization, authentication succeeds..... I understand Oqtane does not keep roles claim in token. Need to figure out why it is not working out.. |
Beta Was this translation helpful? Give feedback.
-
Hurry! @sbwalker I have a working solution with authentication. I will share full sample so that everyone can use it. A minor improvement, I did set a secret in the site for Jwt. How do I retrieve in an ServerStartup? I have hard coded the same secret in the ServerStartup. I tried httpContextAccessor.GetSiteSetting but it is null or even the alias but could not get the token that i configured in the Site Accesing the configured secret is the last pending challenge, we have! I guess it is too easy for you!
@sbwalker you rock! |
Beta Was this translation helpful? Give feedback.
Hi @wcrisafu
You will need to create a startup.cs in your server project and implent it there.