Ends in:
3 DAYS
20 HRS
55 MIN
22 SEC
Ends in:
3 D
20 H
55 M
22 S
Open Closed

Chat Module not working in abp microsevice blazor web assembly project #5211


User avatar
0
raju.thinnaluri@gmail.com created

Hi,

We implemented the Blazor WebAssembly app as a SaaS model in microservice template on abp 7.2.2 version

Added a Chat Module as a package. but chat page not loading. getting the below issue.

  • ABP Framework version: v7.2.2
  • UI type: Blazor WebAssembly
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

31 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    404 not found

    Did you update the gateway ocelot.json file?

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    Yes, Updated ocelot.json file

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    HI,

    Can you share the error logs? Gateway and chat service. thanks.

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi

    Here are the logs,

    **Chat Log: **

    2023-06-08 17:32:26.217 +08:00 [INF] Request origin https://localhost:44307 does not have permission to access the resource. 2023-06-08 17:32:26.506 +08:00 [INF] Executing endpoint 'Volo.Chat.Users.ContactController.GetTotalUnreadMessageCountAsync (Volo.Chat.HttpApi)' 2023-06-08 17:32:26.526 +08:00 [INF] Route matched with {area = "chat", action = "GetTotalUnreadMessageCount", controller = "Contact"}. Executing controller action with signature System.Threading.Tasks.Task1[System.Int32] GetTotalUnreadMessageCountAsync() on controller Volo.Chat.Users.ContactController (Volo.Chat.HttpApi). 2023-06-08 17:32:26.604 +08:00 [INF] Executing action method Volo.Chat.Users.ContactController.GetTotalUnreadMessageCountAsync (Volo.Chat.HttpApi) - Validation state: "Valid" 2023-06-08 17:32:26.768 +08:00 [DBG] PermissionStore.GetCacheItemAsync: pn:U,pk:b4b82d66-d14b-a8ac-fac8-3a0b83a99d0a,n:Chat.Messaging 2023-06-08 17:32:26.779 +08:00 [DBG] Found in the cache: pn:U,pk:b4b82d66-d14b-a8ac-fac8-3a0b83a99d0a,n:Chat.Messaging 2023-06-08 17:32:26.782 +08:00 [DBG] PermissionStore.GetCacheItemAsync: pn:R,pk:admin,n:Chat.Messaging 2023-06-08 17:32:26.788 +08:00 [DBG] Found in the cache: pn:R,pk:admin,n:Chat.Messaging 2023-06-08 17:32:26.790 +08:00 [DBG] PermissionStore.GetCacheItemAsync: pn:C,pk:Blazor,n:Chat.Messaging 2023-06-08 17:32:26.796 +08:00 [DBG] Found in the cache: pn:C,pk:Blazor,n:Chat.Messaging 2023-06-08 17:32:26.886 +08:00 [ERR] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "An internal error occurred during your request!", "details": null, "data": { "ActivatorChain": "Volo.Chat.EntityFrameworkCore.ChatDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions1[[Volo.Chat.EntityFrameworkCore.ChatDbContext, Volo.Chat.EntityFrameworkCore, Version=7.2.2.0, Culture=neutral, PublicKeyToken=null]]" }, "validationErrors": null }

    2023-06-08 17:32:26.886 +08:00 [ERR] An exception was thrown while activating Volo.Chat.EntityFrameworkCore.ChatDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions1[[Volo.Chat.EntityFrameworkCore.ChatDbContext, Volo.Chat.EntityFrameworkCore, Version=7.2.2.0, Culture=neutral, PublicKeyToken=null]]. Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Chat.EntityFrameworkCore.ChatDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions1[[Volo.Chat.EntityFrameworkCore.ChatDbContext, Volo.Chat.EntityFrameworkCore, Version=7.2.2.0, Culture=neutral, PublicKeyToken=null]]. ---> Volo.Abp.AbpException: No configuration found for Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore, Version=7.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60! Use services.Configure<AbpDbContextOptions>(...) to configure it. at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Configure[TDbContext](AbpDbContextOptions options, AbpDbContextConfigurationContext1 context) at Volo.Abp.EntityFrameworkCore.DependencyInjection.DbContextOptionsFactory.Create[TDbContext](IServiceProvider serviceProvider) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) --- End of inner exception stack trace --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider) at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.CreateDbContextAsync(IUnitOfWork unitOfWork) at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.CreateDbContextAsync(IUnitOfWork unitOfWork, String connectionStringName, String connectionString) at Volo.Abp.Uow.EntityFrameworkCore.UnitOfWorkDbContextProvider1.GetDbContextAsync() at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.GetDbSetAsync() at Volo.Abp.Domain.Repositories.EntityFrameworkCore.EfCoreRepository2.GetQueryableAsync() at Volo.Chat.EntityFrameworkCore.Conversations.EfCoreConversationRepository.GetTotalUnreadMessageCountAsync(Guid userId, CancellationToken cancellationToken) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Volo.Chat.Users.ContactAppService.GetTotalUnreadMessageCountAsync() at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Features.FeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.GlobalFeatures.GlobalFeatureInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Authorization.AuthorizationInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Auditing.AuditingInterceptor.ProceedByLoggingAsync(IAbpMethodInvocation invocation, AbpAuditingOptions options, IAuditingHelper auditingHelper, IAuditLogScope auditLogScope) at Volo.Abp.Auditing.AuditingInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo) at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue1.ProceedAsync() at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation) at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) at lambda_method1301(Closure, Object) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2023-06-08 17:32:26.888 +08:00 [ERR] ---------- Exception Data ---------- ActivatorChain = Volo.Chat.EntityFrameworkCore.ChatDbContext -> λ:Microsoft.EntityFrameworkCore.DbContextOptions`1[[Volo.Chat.EntityFrameworkCore.ChatDbContext, Volo.Chat.EntityFrameworkCore, Version=7.2.2.0, Culture=neutral, PublicKeyToken=null]]

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    No configuration found for Microsoft.EntityFrameworkCore.DbContext, Microsoft.EntityFrameworkCore, Version=7.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60! Use services.Configure<AbpDbContextOptions>(...) to configure it.

    You are installing the chat module to product service, right? You can try:

    public class ProductServiceDbContext : AbpDbContext<ProductServiceDbContext>, IChatDbContext
    ....
    
    
    context.Services.AddAbpDbContext<ProductServiceDbContext>(options =>
    {
        options.ReplaceDbContext<IChatDbContext>();
        options.AddDefaultRepositories(includeAllEntities: true);
    });
    
  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    The above issue i able to solve. adding from abp suite not done all the changes required to run the chat module.

    1. in Entity Framework project Dbcontaxt it missed the below
    2. in Entity Framework module missed the flowing line

    Now we are getting the flowing errors,

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You need to configure the SignalR URL.

    For example:

    Configure<ChatBlazorWebAssemblyOptions>(options =>
    {
        options.SignalrUrl = builder.Configuration["RemoteServices:Chat:BaseUrl"];
    });
    
  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    You need to configure the SignalR URL.

    For example:

    Configure<ChatBlazorWebAssemblyOptions>(options => 
    { 
        options.SignalrUrl = builder.Configuration["RemoteServices:Chat:BaseUrl"]; 
    }); 
    

    Hi,

    Where i should write this line Product service? and should i update anything in app settings of Product service?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You should write this in the Blazor app.

    and should i update anything in app settings of Product service?

    No, you don't.

    Could not find VoloChatAvatarManager.createCanvasForUser

    You can try running the abp bundle command in the Blazor app folder.

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    Added the this line in Main Blazor app

    and ran the abp bundle

    but still getting the issue as follows

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It's just an example; you should replace the builder.Configuration["RemoteServices:Chat:BaseUrl"]; with the real URL.

    Gateway URL or Product service URL.

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    I given the Web gateway URL, now getting the below error.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Update the gateway config file:

    {
        "ServiceKey": "Signalr Service",
        "DownstreamPathTemplate": "/signalr-hubs/{everything}",
        "DownstreamScheme": "wss",
        "DownstreamHostAndPorts": [
        {
        "Host": "localhost",
        "Port": 44361
        }
        ],
        "UpstreamPathTemplate": "/signalr-hubs/{everything}",
        "UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
    },
    
  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    Added the Configuration, and added the app.UseWebSockets(); in web gateway module.

    but still getting the below error.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you share the project with me? I will check it out

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    My email is shiwei.liang@volosoft.com

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi, This is the Error in log

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Sorry, I am missing a verb.

    You can remove the UpstreamHttpMethod to allow any verbs:

    {
        "ServiceKey": "Signalr Service",
        "DownstreamPathTemplate": "/signalr-hubs/{everything}",
        "DownstreamScheme": "wss",
        "DownstreamHostAndPorts": [
        {
        "Host": "localhost",
        "Port": 44361
        }
        ],
        "UpstreamPathTemplate": "/signalr-hubs/{everything}"
    }
    
  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    Now new Error,

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you share the project with me? shiwei.liang@volosoft.com, I will check it out. I think this can save you time.

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    I uploaded and shared the source code to you email id shiwei.liang@volosoft.com.

    you may check.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Steps:

    • Update the appsettings.json
      "RemoteServices": {
        "AbpIdentity": {
          "BaseUrl": "https://localhost:44388/",
          "UseCurrentAccessToken": "false"
        }
      },
      "IdentityClients": {
        "Default": {
          "GrantType": "client_credentials",
          "ClientId": "AdministrationService",
          "ClientSecret": "1q2w3e*",
          "Authority": "https://localhost:44322",
          "Scope": "IdentityService",
          "RequireHttps": "true",
          "ValidateIssuerName": "true",
          "ValidateEndpoints ": "true"
        }
      },
    
    • Grant user lookup permission to AdministrationService

    You can create an application named ProductService instead of using AdministrationService

    • Add package references

    <PackageReference Include="Volo.Abp.Identity.Pro.HttpApi.Client" Version="7.2.2" /> <PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="7.2.2" />

    [DependsOn(typeof(AbpHttpClientIdentityModelWebModule))]
    [DependsOn(typeof(AbpIdentityHttpApiClientModule))]
    public class ProductServiceHttpApiHostModule : AbpModule
    
    • Update ProductServiceHttpApiHostModule
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
    {
        var app = context.GetApplicationBuilder();
        var env = context.GetEnvironment();
    
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
    
        app.Use(async (httpContext, next) =>
        {
            var accessToken = httpContext.Request.Query["access_token"];
    
            var path = httpContext.Request.Path;
            if (!string.IsNullOrEmpty(accessToken) &&
                (path.StartsWithSegments("/signalr-hubs/chat")))
            {
                httpContext.Request.Headers["Authorization"] = "Bearer " + accessToken;
            }
    
            await next();
        });
        
        ........
    }
    
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

  • User Avatar
    0
    raju.thinnaluri@gmail.com created

    Hi,

    Now Application loading and chat working.

    but may i know why we should use web reference in host module?

    <PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="7.2.2" />

    since my project is Blazor web assembly.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Because the product service needs to load user information from the identity service and the package was added to ProductService.HttpAPI.Host not the Blazor app.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 02, 2024, 12:35