Ends in:
7 DAYS
21 HRS
23 MIN
2 SEC
Ends in:
7 D
21 H
23 M
2 S

Activities of "wazbek"

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, Func3 proceed) at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.OnConnectedAsync(HubConnectionContext connection) at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher1.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?

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.

Managed to sort this out by adding this to the EntityFrameworkCoreModule.cs file

options.AddDefaultRepositories(includeAllEntities: true);

Hi

I managed to find an issue on the server side by looking at the logs. My services are not being resolved. See error below.

I have placed my Hub class in my Application.csproj. I know the docs recommend either web or api projects but I need to get the IHubContext in my application service to be able to send data back to the hub.

This is what I would like to achieve. Angular frontend communicates to the hub. The hub then calls to my application service and from there I want to be able to send data back to the Angular frontend using the IHubContext.

I have had a look at the SignalRTieredDemo application and I see that the hub is in the Web project and there is a ReceivedMessageEventHandler that handles an event that gets published from the ChatAppService.

Do I need to stick to this architecture or is there another way for me to get this to work as described above?

Would I also need to use the event bus to publish events from my hub to my application service rather than injecting my application service directly into the hub? I am currently getting this error when injecting the application service into my hub:

2020-08-03 08:13:22.994 +02:00 [ERR] Error when dispatching 'OnConnectedAsync' on hub.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating NexModule.Cmt.IdmHub -> NexModule.Cmt.IdmEngineService -> NexModule.Cmt.Services.IdmBidAndAskDataDomainService -> NexModule.Cmt.Services.IdmTradingIntervalDataDomainService -> NexModule.Tsam.TsamInterconDomainService.
 ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'NexModule.Tsam.TsamInterconDomainService' can be invoked with the available services and parameters:
Cannot resolve parameter 'Volo.Abp.Domain.Repositories.IRepository`2[NexModule.Tsam.Domain.TsamInterconCapacity,System.Int32] interconCapacityRepository' of constructor 'Void .ctor(NexModule.Tsam.IInterconDapperRepository, Volo.Abp.Domain.Repositories.IRepository`2[NexModule.Tsam.Domain.TsamInterconCapacity,System.Int32])'.
   at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(ConstructorInfo[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.CreateInstance(IEnumerable`1 parameters)
   --- End of inner exception stack trace ---
   at Autofac.Core.Resolving.InstanceLookup.CreateInstance(IEnumerable`1 parameters)
   at Autofac.Core.Resolving.InstanceLookup.Execute()
   at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.ResolveComponent(ResolveRequest request)
   at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request)
   at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request)
   at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
   at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
   at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.AspNetCore.SignalR.Internal.DefaultHubActivator`1.Create()
   at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.OnConnectedAsync(HubConnectionContext connection)
   at Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher`1.OnConnectedAsync(HubConnectionContext connection)
   at Microsoft.AspNetCore.SignalR.HubConnectionHandler`1.RunHubAsync(HubConnectionContext connection)

Thanks.

Hi Mehmet

Thanks for taking a look. Your recommendation pointed me in the right direction and I managed to find what was causing the issue.

I started by importing everything into my app module again like this:

imports: [
    BrowserModule,
    BrowserAnimationsModule,
    AppRoutingModule,
    ThemeSharedModule.forRoot({
      httpErrorConfig: {
        errorScreen: {
          component: HttpErrorComponent,
          forWhichErrors: [401, 403, 404, 500],
          hideCloseIcon: true,
        },
      },
    }),
    CoreModule.forRoot({
      environment,
    }),
    AccountConfigModule.forRoot({ redirectUrl: '/' }),
    IdentityConfigModule,
    LanguageManagementConfigModule,
    SaasConfigModule,
    AuditLoggingConfigModule,
    IdentityServerConfigModule,
    TextTemplateManagementConfigModule,
    SettingManagementConfigModule,
    NgxsModule.forRoot([]),
    SharedModule,

    ...(environment.production ? [] : LOGGERS),

Which got my application working witout any errors. I then started moving them one by one to my shell module file that i sent you and I then realised the NgxsModule.forRoot([]) import. I was importing the NgxsModule like this in my core module:

export const ngxsConfig: NgxsModuleOptions = {
  //developmentMode: !environment.production,
  selectorOptions: {
    suppressErrors: false,
    injectContainerState: false
  }
};

@NgModule({
  imports: [
    CommonModule,
    NgxsModule.forRoot([], ngxsConfig),
    NgxsFormPluginModule.forRoot(),
    NgxsReduxDevtoolsPluginModule.forRoot({ disabled: environment.production }),
    ...(environment.production ? [] : LOGGERS)
  ]
})
export class CoreModule {

The NgxsModuleOptions that I had set will only be used in NGXS v4. I removed the ngxsConfig from my NgxsModule import and everything works as expected now. https://www.ngxs.io/advanced/options. This was working before ABP version 2.8.

Sorry for waisting your time.

Thanks again.

Hi Mehmet

Yes we did, we used ABP Suite 2.8 to do the update.

We are using an nx workspace(https://nx.dev/angular/getting-started/why-nx) so our app.module.ts file does not have all the modules imported like a normal angular app. I have follow the order of module imports in our nx workspace by looking at a newly created angular application using abp version 2.8.

I will email the files to info@abp.io.

Hi

We are getting some errors after updating to version 2.8. We are using the Angular frontend.

This error happens when the app loads up:

core.js:6210 ERROR TypeError: Cannot read property 'objectExtensions' of undefined
    at ɵ1 (volo-abp.commercial.ng.ui.js:3358)
    at wrappedSelectorFn (ngxs-store.js:2865)
    at memoized (ngxs-store-internals.js:59)
    at selectFromRoot (ngxs-store.js:2901)
    at ngxs-store.js:2896
    at Array.map (<anonymous>)
    at MapSubscriber.selectFromRoot [as project] (ngxs-store.js:2892)
    at MapSubscriber._next (map.js:29)
    at MapSubscriber.next (Subscriber.js:49)
    at StateStream._subscribe (BehaviorSubject.js:14)

There are also these warnings in the browser console:

Could not find localization source: TextTemplateManagement   abp-ng.core.js:1014

The localization source separator (::) not found.  abp-ng.core.js:1014

All the abp screens are displaying like this too:

Showing 11 to 20 of 39 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06