Need help on the grpc service side. I was not able to get data through repository while using grpc service. That is weird because I was following the guide from
https://docs.abp.io/en/commercial/7.4/startup-templates/microservice/using-grpc. Everything going okay except repository side did not return me the data it should.
It keeps returns There is no such an entity
but there is with the Id provided.
I am using abp commercial for this. The grpc client is called from gateway and server is in microservice, not sure this will affect anything or not?
Attach with some images to help understand more on my situation.
- ABP Framework version: v7.4.3
- UI Type: MVC
- Database System: EF Core (MySQL)
- Tiered (for MVC) or Auth Server Separated (for Angular): yes
5 Answer(s)
-
0
Hi,
I guess it may be due to multi-tenant data isolation.
You can check it by debugging or outputting logs:
Guid tenantGuid = ....; logger.LogInformation($"------ TenantGuid is {tenantGuid}"); using(CurrentTenant.Change(tenantGuid)) { var apiSecretKey = Guid.Parse(request.ApiSecretKey); logger.LogInformation($"------ ApiSecretKey is {apiSecretKey}"); var saasKeyChain = await _saasKeyChainRepository.FindAsync(apiSecretKey); if(saasKeyChain == null) { throw new UserFriendlyException(.....); } }
-
0
I did try debug and those keys are in position, just not sure why the repository does not give any results. Even I use
FirstOrDefaultAsync()
, still it returns empty. But i double check with my ApplicationAppService, that one works fine. Still cant figure out what is the issue. Or you mind to explain about the multi-tenant data isolation? -
0
Hi,
Or you mind to explain about the multi-tenant data isolation?
Ok, if the entity implements a
IMultiTenant
interface. a tenant(and host) can not access to data of another tenant by default.https://docs.abp.io/en/abp/latest/Multi-Tenancy#imultitenant
You can check the
TenantId
value in the database table record.According to your case, the ApiSecret
3a0f98fc-179f.....
's TenantId should be3a0f9797-934e-16b0....
-
0
Hi,
Or you mind to explain about the multi-tenant data isolation?
Ok, if the entity implements a
IMultiTenant
interface. a tenant(and host) can not access to data of another tenant by default.https://docs.abp.io/en/abp/latest/Multi-Tenancy#imultitenant
You can check the
TenantId
value in the database table record.According to your case, the ApiSecret
3a0f98fc-179f.....
's TenantId should be3a0f9797-934e-16b0....
Okay, I think this is the main issue causing me unable to get this current tenant's record from Repository. Anyway to access tenants's data through grpc? or grpc only can get
host
data? -
0
Hi,
You can change the current tenant to get tenant data:
using(CurrentTenant.Change(tenantGuid)) { var saasKeyChain = await _saasKeyChainRepository.FindAsync(apiSecretKey); if(saasKeyChain == null) { throw new UserFriendlyException(.....); } }