Open Closed

Questions multi tenancy feature #5511


User avatar
0
datdv1 created

Hi ABP support team We a using abp commercial

  • UI framework: angular
  • ABP Version: 7.2.3
  • Data access: MongoDB This solution deployed to AKS and running Currently, we want to enable and implement multitenancy feature on this solution. With each tenant is initialized , I need each tenant to have its own database , logo and branch name

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

    Hi,

    It's possible.

    You can check the document:

    • https://docs.abp.io/en/abp/latest/Multi-Tenancy
    • https://docs.abp.io/en/commercial/latest/modules/saas

    logo and branch name

    You can custom the brand component to display a different brand and logo for each tenant https://docs.abp.io/en/commercial/latest/themes/lepton-x/angular#brand-component

  • User Avatar
    0
    datdv1 created

    Hi liangshiwei I implemented with the document: https://docs.abp.io/en/abp/latest/Multi-Tenancy It works on local, But I got the error after deployed to AKS, Can you suggest solution for this. We are using mongo db replicaset, and the error mesage shows like below:

    A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "4", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [] }.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share the full error logs? thanks.

  • User Avatar
    0
    datdv1 created

    Hi liangshiwei Here is the log:

    A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "4", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [] }. System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "4", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [] }. at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description) at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask) at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken) at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.StartImplicitSession(CancellationToken cancellationToken) at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken) at MongoDB.Driver.MongoDatabaseImpl.UsingImplicitSession[TResult](Func2 func, CancellationToken cancellationToken) at MongoDB.Driver.MongoDatabaseImpl.ListCollectionNames(ListCollectionNamesOptions options, CancellationToken cancellationToken) at Volo.Abp.MongoDB.MongoModelBuilder.CreateCollectionIfNotExists(AbpMongoDbContext dbContext, String collectionName) at Volo.Abp.MongoDB.MongoModelBuilder.Build(AbpMongoDbContext dbContext) at Volo.Abp.MongoDB.MongoModelSource.CreateModel(AbpMongoDbContext dbContext) at Volo.Abp.MongoDB.MongoModelSource.<>c__DisplayClass1_0.<GetModel>b__0(Type _) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Volo.Abp.MongoDB.AbpMongoDbContext.InitializeCollections(IMongoDatabase database) at LogisticsTico.MongoDB.MongoDbLogisticsTicoDbSchemaMigrator.MigrateAsync() in D:\datdv\project\CShap\final_project\LogisticsTico\aspnet-core\src\LogisticsTico.MongoDB\MongoDb\MongoDbLogisticsTicoDbSchemaMigrator.cs:line 49 A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "4", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [] }. System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "4", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [] }. at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description) at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask) at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken) at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken) at MongoDB.Driver.MongoClient.StartImplicitSession(CancellationToken cancellationToken) at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken) at MongoDB.Driver.MongoDatabaseImpl.UsingImplicitSession[TResult](Func2 func, CancellationToken cancellationToken) at MongoDB.Driver.MongoDatabaseImpl.ListCollectionNames(ListCollectionNamesOptions options, CancellationToken cancellationToken) at Volo.Abp.MongoDB.MongoModelBuilder.CreateCollectionIfNotExists(AbpMongoDbContext dbContext, String collectionName) at Volo.Abp.MongoDB.MongoModelBuilder.Build(AbpMongoDbContext dbContext) at Volo.Abp.MongoDB.MongoModelSource.CreateModel(AbpMongoDbContext dbContext) at Volo.Abp.MongoDB.MongoModelSource.<>c__DisplayClass1_0.<GetModel>b__0(Type _) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Volo.Abp.MongoDB.AbpMongoDbContext.InitializeCollections(IMongoDatabase database) at LogisticsTico.MongoDB.MongoDbLogisticsTicoDbSchemaMigrator.MigrateAsync() in D:\datdv\project\CShap\final_project\LogisticsTico\aspnet-core\src\LogisticsTico.MongoDB\MongoDb\MongoDbLogisticsTicoDbSchemaMigrator.cs:line 49

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    It looks like a problem with the MongoDB driver.

    Here is some information that might be useful: https://www.google.com/search?q=WaitForDescriptionChangedHelper+site:www.mongodb.com&sxsrf=AB5stBggHEDVtpC-rhwe1L8woOD-mncgJg:1691032670349&sa=X&ved=2ahUKEwiJqvrMw7-AAxWbHHAKHUEzAcIQrQIoBHoECBMQBQ&biw=1920&bih=857&dpr=2

  • User Avatar
    0
    datdv1 created

    Thanks liangshiwei reply for me! I have one more question to ask. Yesterday, I tried the following steps:

    1. use <db_name> in mongo db
    2. create tenant in UI angular with format connectionString: mongodb://<user>:<password>@<replicaset_name>/<db_name>

    I got the error: Cannot create namespace <db_name>.AbpPermissionGrants in multi-document transaction Is it also to this problem?

  • User Avatar
    0
    datdv1 created

    I have one more question to ask. I want one tenan to have its own domain, Can you suggesst for me implement solution this? And I also want the way how to implement it both of following solutions:

    1. Authentication is not separated module
    2. Authentication is a separated module
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    use <db_name> in mongo db

    create tenant in UI angular with format connectionString: mongodb://<user>:<password>@<replicaset_name>/<db_name> I got the error: Cannot create namespace <db_name>.AbpPermissionGrants in multi-document transaction

    I will check it.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I have one more question to ask. I want one tenan to have its own domain, Can you suggesst for me implement solution this? And I also want the way how to implement it both of following solutions: Authentication is not separated module Authentication is a separated module

    Please create a new question, thanks.

  • User Avatar
    0
    datdv1 created

    Thanks liangshiwei!

  • User Avatar
    0
    datdv1 created

    Hi liangshiwei I want one tenan to have its own domain, Can you suggesst for me implement solution this?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I think the document can help you:

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#determining-the-current-tenant

    ABP provide the domain tenant resolve

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#domain-subdomain-tenant-resolver

  • User Avatar
    0
    datdv1 created

    Thanks liangshiwei I have one more question to ask. Yesterday, I reviewed feature multitenant in my local, I see create first tenant has initialized all collections that host tenant has. But when I create second tenant , I dont see it initialized all collections like host tenant.(Host tenant has about 60 collections, first tenant has 60 collections as host tenant, second tenant has only 7 collections) Is this is bug? How can I resolve ?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, I didn't get it, could you share some screenshots? thanks.

  • User Avatar
    0
    datdv1 created

    Hi liangshiwei Here is the screenshorts

    screenshort error:

    screenshort List db for main tenant - because we have more than 60 collections, a image cannot capture all colelctions:

    screenshort List collections for first tenant - it have enough collection:

    screenshort List collection for second tenant - it only has 7 collections:

  • User Avatar
    0
    datdv1 created

    Hi,

    I think the document can help you:

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#determining-the-current-tenant

    ABP provide the domain tenant resolve

    https://docs.abp.io/en/abp/latest/Multi-Tenancy#domain-subdomain-tenant-resolver

    Thanks! I'm newbie of ABP framework! I think it is more efficience to make some online meeting. We can easily do it step by step?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Here is the screenshorts

    screenshort error:

    This looks like a problem, I'll check it

    We can easily do it step by step?

    This is a big topic, you can try to implement, if you encounter problems, we will be happy to help you

  • User Avatar
    0
    datdv1 created

    Here is the screenshorts

    screenshort error:

    This looks like a problem, I'll check it

    We can easily do it step by step?

    This is a big topic, you can try to implement, if you encounter problems, we will be happy to help you

    Thanks liangshiwei, I looking forward to your response

  • User Avatar
    0
    datdv1 created

    Hi liangshiwei, I want to modify SaaS module so that each tenant has its own logo, company name, and domain. When users access their tenant domain (url), the application automatically switch to their tenant with their own logo and company name. Could you please advise me steps to implement this feature in order to follow ABP best practices. Many thanks in advance.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Thanks liangshiwei, I looking forward to your response

    The Collections will be created dynamically, you can ignore this problem, we have suppressed this error message in the latest version

    I want to modify SaaS module so that each tenant has its own logo, company name, and domain. When users access their tenant domain (url), the application automatically switch to their tenant with their own logo and company name. Could you please advise me steps to implement this feature in order to follow ABP best practices. Many thanks in advance.

    In short, there are two steps.

    • Override the component
    • Use logical checks to display different logos

    You can custom the brand component

    • https://docs.abp.io/en/commercial/latest/themes/lepton-x/angular#brand-component

    And for auth server login page you can override the account layout page

    https://docs.abp.io/en/commercial/latest/themes/lepton-x/mvc#account-layout

    For example (Auth server login page)

    https://gist.github.com/realLiangshiwei/1f284183284f611fd6fe5bb0890bd781

    You can download the LeptonX theme source code via ABP Suite

  • User Avatar
    0
    datdv1 created

    Hi liangshiwei I'm using Authentication is not separated module. How i can custom login page on my solution? Could you please show me where is the login page inside the source code, please give me a screen shot of login page. The Collections will be created dynamically So how long collections will be created?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I'm using Authentication is not separated module. How i can custom login page on my solution? Could you please show me where is the login page inside the source code, please give me a screen shot of login page.

    Source code is here: https://gist.github.com/realLiangshiwei/1f284183284f611fd6fe5bb0890bd781

    You need to put the in the Themes/LeptonX/Layouts/Account folder of the .AuthServer project:

    This is actually explained in the document : )

    The Collections will be created dynamically So how long collections will be created?

    When the collection will be created the first time it is used

  • User Avatar
    0
    datdv1 created

    When the collection will be created the first time it is used

    I mean how many minutes does it need to create collections and how many minutes does it need to create initialized data Let say when I create tenant at 14:00, so it takes 5 minutes to create all collection and initialized data, right?

    You need to put the in the Themes/LeptonX/Layouts/Account folder of the .AuthServer project

    When I creating solution I choose not to separate option, so that in project. AuthServer module is not a separated module Currently, I want to custom the login page, Could you please show me where is the login page inside the source code, please give me a screen shot of login page. (Because the Auth server is not an separated module, if you have any source code that config like this, please send me )

  • User Avatar
    0
    datdv1 created

    here is the screen short my solution:

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    here is the screen short my solution:

    Should be .HttpApi.Host project.

Made with ❤️ on ABP v9.1.0-preview. Updated on October 11, 2024, 07:13