Hi Mehmet,
Email sent to you.
Regards,
Warick
Hi Mehmet
I see the documentation for replacing the nav items component got changed yesterday. I have followed the new steps and was able to reproduce the problem.
I have emailed an application that reproduces the problem to info @ abp.io.
Please let me know if you need anything else.
Regards,
Warick
Hi
We added a custom Nav Items Component which was working correctly by following the steps here: https://docs.abp.io/en/abp/latest/UI/Angular/Component-Replacement#how-to-replace-a-layout
After updating to ABP version 4.3.0 our custom component displays like this whether we are logged in or not:
Please advise if there is a new way of creating the nav items component or if there is something else I need to do to get this to work as before.
Thanks.
Warick
Hi liangshiwei
Thank you very much for taking the time to create a sample project. That is exactly what I needed to find what my problem was.
I am able to connect to my hub and get the id of the current user now.
Thanks again.
Hi liangshiwei
I currently dont have any time to setup a sample project to reproduce this.
Can you please provide me with a sample project or sample code with the steps I need to perform to get an Angular frontend connecting to a Hub that needs the user to be authorized. I need to get the Currentusers id value in the OnConnectedAsync() method of the hub.
This is not documented anywhere and all signalR samples are using the MVC frontends.
Thanks.
Which token? I have logged out and logged back in and I still receive the same error.
Here is the log output on the server side.
2020-09-07 08:15:57.335 +02:00 [Error] (Microsoft.AspNetCore.SignalR.HubConnectionHandler.) Error when dispatching '"OnConnectedAsync"' on hub.
Volo.Abp.Authorization.AbpAuthorizationException: Authorization failed! Given policy has not granted.
at Microsoft.AspNetCore.Authorization.AbpAuthorizationServiceExtensions.CheckAsync(IAuthorizationService authorizationService, AuthorizationPolicy policy)
at Volo.Abp.Authorization.MethodInvocationAuthorizationService.CheckAsync(MethodInvocationAuthorizationContext context)
at Volo.Abp.Authorization.AuthorizationInterceptor.AuthorizeAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func
3 proceed)
at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.OnConnectedAsync(HubConnectionContext connection) at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher
1.OnConnectedAsync(HubConnectionContext connection)
at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)
2020-09-07 08:16:06.393 +02:00 [Debug] (IdentityServer4.AccessTokenValidation.IdentityServerAuthenticationHandler.) AuthenticationScheme: "Bearer" was successfully authenticated.
2020-09-07 08:16:06.396 +02:00 [Debug] (IdentityServer4.Hosting.CorsPolicyProvider.) CORS request made for path: "/signalr-hubs/idm" from origin: "http://localhost:4200" but was ignored because path was not for an allowed IdentityServer CORS endpoint
Which policy has not been granted? I am using the [Authorize] attribute.
Hi liangshiwei
This is my code.
constructor(private oAuthService: OAuthService) {
this.buildConnection();
this.startConnection();
this.initEvents();
}
private buildConnection() {
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl(environment.apis.default.url + this.idmHubUrl, {
accessTokenFactory: () => this.oAuthService.getAccessToken(),
})
.build();
}
private startConnection() {
this.hubConnection
//.invoke("Join")
.start()
.then(() => {
this.hubConnectionEstablished$.next(true);
})
.catch((err) => {
console.error('Error while starting connection: ' + err);
});
}
If I use the .invoke("Join") I get this error in the browser console. None of my breakpoints on the hub constructor or OnConnectedAsync are hit.
If I use .start() my breakpoint on the hub constructor gets hit but not the breakpoint on the OnConnectedAsync method and I receive the following error in the browser console.
Am I missing some extra setup on the server side to get this to work?
Check the docs before asking a question: I have checked the docs and the samples and there is nothing documented on how to get Angular and signalR working with Abp. I found this github issue https://github.com/abpframework/abp/issues/5239 but it is still not clear on how this should be done.
``` this.hubConnection = new signalR.HubConnectionBuilder() .withUrl(environment.apis.default.url + this.idmHubUrl ).build(); ```
I need to be able to get the CurrentUser.Id in the OnConnectedAsync() of my hub.
public override async Task OnConnectedAsync()
{
_connections.Add(CurrentUser.Id.Value, Context.ConnectionId);
await base.OnConnectedAsync();
}
I have added the [Authorize] attribute to my hub class. With this in place I receive the exception message above. If I remove the attribute I am able to connect to the hub but then obviously the CurrentUser.Id value is null.
Please provide a working example of how I can get this to work.
Thanks.
Hi Nick
We didnt install RabbitMQ. Our system is a modular monolith for the moment.
However it doesnt mean you cant use the distributed event bus. From the Distributed Event Bus documentation https://docs.abp.io/en/abp/latest/Distributed-Event-Bus: "LocalDistributedEventBus is the default implementation that implements the distributed event bus to work as in-process. Yes! The default implementation works just like the local event bus, if you don't configure a real distributed provider."
Hope that helps.
Hi Nick
I'm good thanks.
This sample helped me a lot to figure out how get my application working: https://github.com/abpframework/abp-samples/tree/master/SignalRTieredDemo.
Yes I moved my hub into the HttpApi project. I basically followed the same architecture in the sample above and got it working. I am not injecting those 2 parameters into my constructor though so I am not sure I can be of any help to you.
Hopefully ABP provide you with a solution.