Open Closed

Receiving HttpStatusCode 404 when executing endpoints from 2nd service #8303


User avatar
0
suresht created
  • ABP Framework version: v8.3.0
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://dev.web-gateway.integrationservices.dev.aws.test.com/api/client/v1/test/contractlocations, Response status code: 404
  • Steps to reproduce the issue:

We have a microservice that has reference to 2 services. When executing endpoints from 1st service, they work. However, when executing endpoints from 2nd service, we get a 404 error. Below are code details:

(Host) Module class from Microservice
=====================================
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        Configure<AbpAspNetCoreMvcOptions>(options =>
        {
            options
                .ConventionalControllers
                .Create(typeof(IntegrationServicesProjectServiceModule).Assembly, opts =>
                {
                    opts.RemoteServiceName = "ProjectService";
                    opts.RootPath = "project";
                });
        });
    }

(Service 1)  Module class from HttpApi project
==============================================
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        PreConfigure<IMvcBuilder>(mvcBuilder =>
        {
            mvcBuilder.AddApplicationPartIfNotExists(typeof(ProjectHttpApiModule).Assembly);
        });

        PreConfigure<AbpAspNetCoreMvcOptions>(options =>
        {
            //1.0 Compatibility version
            options.ConventionalControllers.Create(typeof(ProjectApplicationModule).Assembly, opts =>
            {
                opts.TypePredicate = t => t.Namespace == typeof(CapsPay.v1.CapspayprojectAppService).Namespace;
                //opts.ApiVersions.Add(new ApiVersion(1, 0));
                opts.RootPath = "project/v1";
                opts.UrlControllerNameNormalizer = context =>
                {
                    return context.ControllerName.Replace("project", string.Empty, System.StringComparison.InvariantCultureIgnoreCase);
                };
            });
        });
    }

(Service 2) - Module class from HttpApi project
===============================================
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        PreConfigure<IMvcBuilder>(mvcBuilder =>
        {
            mvcBuilder.AddApplicationPartIfNotExists(typeof(ClientHttpApiModule).Assembly);
        });

        PreConfigure<AbpAspNetCoreMvcOptions>(options =>
        {
            //1.0 Compatibility version
            options.ConventionalControllers.Create(typeof(ClientApplicationModule).Assembly, opts =>
            {
                opts.TypePredicate = t => t.Namespace == typeof(CapsPay.v1.CapspayclientAppService).Namespace;
                //opts.ApiVersions.Add(new ApiVersion(1, 0));
                opts.RootPath = "client/v1";
                opts.UrlControllerNameNormalizer = context =>
                {
                    return context.ControllerName.Replace("client", string.Empty, System.StringComparison.InvariantCultureIgnoreCase);
                };
            });
        });
    }

If I change the value, "client/v1" to "project/v1" in service 2, the endpoints from 2nd service work. However, the pathing is not correct and it means that if another microservice has reference to this 2nd service, then we have to change the RootPath value in 2nd service to the new microservice name. This does not seem logical.

Can you please let me know what the issue is? I tried finding articles giving an insight into this implementation but did not find any.

Please let me know if you need any additional information.

Thanks in advance,

Suresh


20 Answer(s)
  • User Avatar
    0
    suresht created

    Hello,

    Following up to find out if you will be able to provide assistance on this ticket?

    Thanks in advance,

    Suresh

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I can't see any difference between services 1 and 2.

    could you please use a new project to reproduce the problem? I will check it. my email is shiwei.liang@volosoft.com

  • User Avatar
    0
    suresht created

    Hi Liang,

    The differences are with the following:

    • opts.TypePredicate
    • opts.RootPath

    I will share a OneDrive link to the full source code to the email you listed.

    Thanks,

    Suresh

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    okay, i will check it

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I can't build the solution

  • User Avatar
    0
    suresht created

    Hi,

    The code I shared with you has Nuget references. I uploaded now with project references. I will re-share the OneDrive link.

    The code compiles but I am unable to verify everything is working as I am running into an error when launching abp studio to get the docker images started. The error I am running into is the same that others are reporting:

    Could not retrieve the OpenId Connect discovery document! ErrorType: Http. Error: Error connecting to https://account.abp.io/.well-known/openid-configuration: Forbidden

    Are you able to review the Module classes in the host and two services to determine if everything looks correct?

    Before the issue with abp.io studio auth error, the code running locally with project references worked. However, when building the services as Nuget packages and deployed to our dev site, we run into the error reported in this ticket.

    Thanks,

    Suresh

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi

    Could not retrieve the OpenId Connect discovery document! ErrorType: Http. Error: Error connecting to https://account.abp.io/.well-known/openid-configuration: Forbidden

    The problem was fixed ,you can check it again.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    The code I shared with you has Nuget references. I uploaded now with project references. I will re-share the OneDrive link.

    The project you shared is incomplete, I can't build it.

  • User Avatar
    0
    suresht created

    Hi,

    I have shared all the files for the three (host, service1 and service2) solutions. These are copies of all the files from my machine after successful compilation.

    Looking forward to your feedback.

    Thanks,

    Suresh

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I think you just copied part of the project, not all. That's why I can't build it.

    And the shared file hasn't been updated.

  • User Avatar
    0
    suresht created

    Hi,

    I created a new OneDrive folder and copied all files there and shared with you:

    Thanks for your patience.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, Unfortunately, it is still not complete. Can I check it remotely?

  • User Avatar
    0
    suresht created

    Hi,

    The microservice (host) has project references to Project Service (module). The screenshot above shows the relative path to the module on my machine based on our repo working folder.

    Is it possible for you to change these to the Client and Project module locations on your machine? I use ABP Studio to set/fix the project references:

    Please let me know if that works.

    Thanks

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    We have a microservice that has reference to 2 services. When executing endpoints from 1st service, they work. However, when executing endpoints from 2nd service, we get a 404 error.

    I can only see that your Project service only references the CastandCrew.Payroll.Project service, I think that's the problem.

  • User Avatar
    0
    suresht created

    Hi,

    The version we are testing has project reference to Client module. Testing locally (localhost), the Client endpoints work.

    When deployed and using Nuget packages for Client and Project, the endpoints for Project work. We get the 404 error for Client endpoints.

    I have updated the csproj file on the OneDrive location shared with you to include project references to Client module. You will have to update the location to the one appropriate for yours via Abp Studio.

    Thanks

  • User Avatar
    0
    suresht created

    Hi,

    Do you have an insight into the issue? Do you need any more information than provided?

    We would like to resolve the issue as we need to get it deployed soon.

    Thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I can't reproduce the problem.

    I added Client module Dependencies, and they are all of them can be reachable.

  • User Avatar
    0
    suresht created

    Hi,

    Everything works on my side locally as it is on your side. As previously stated, when we deploy to our dev server, then the Client endpoints fail with 404.

    Thanks.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Could you share the full logs?

  • User Avatar
    0
    suresht created

    Hi,

    The information from our log which is also stated in the Exception details/Stack Trace portion of the ticket is :

    Request reached the end of the middleware pipeline without being handled by application code. Request path: GET http://dev.web-gateway.integrationservices.dev.aws.test.com/api/client/v1/test/contractlocations, Response status code: 404

    Eventually, we were able to figure out the issue.

    Thanks.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09