ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.32k stars 1.63k forks source link

Getting error due to serviceDiscoveryProvider in GlobalConfiguration after update to 18.0.0 from 13.0.0 #1715

Closed bob5296 closed 9 months ago

bob5296 commented 11 months ago

I had this config in ocelot.json

 "GlobalConfiguration": {
    "RequestIdKey": "OcRequestId",
    "ServiceDiscoveryProvider": {
      "Host": "********DNSname",
      "Port": 19081,
      "Type": "ServiceFabric"
    }

and in route

{
      "DownstreamPathTemplate": "/api/Configuration/{url}",
      "UpstreamPathTemplate": "/Configuration-API/{url}",
      "UpstreamHttpMethod": [
        "Get",
        "Options",
        "Post",
        "Put",
        "Delete"
      ],
      "DownstreamScheme": "http",
      "ServiceName": "ServiceNameInServiceFabric"
}

Before upgrade it was not searching for the DNS provided in GlobalConfiguration and it was working. After upgrade it started giving below error:

Ocelot.Responder.Middleware.ResponderMiddleware[0]
     requestId: 0HMU5N5H75RMD:00000002, previousRequestId: no previous request id, message:
     Error Code: ConnectionToDownstreamServiceError
     Message: Error connecting to downstream service, exception:
     System.Net.Http.HttpRequestException: No such host is known.

Any particular reason it was not giving error in versions 13 but started giving error in version 18

raman-m commented 11 months ago

Hi Bob! How do you host your Ocelot app? What is the hosting environment?

Please provide a description of hosting environments for both: client and server. Ocelot app and downstream service.

Also, make Postman requests directly to downstream service:

Attach all screenshots please...

Also, provide full calling stack from debugging in case of error.

Without additional details I cannot advice you something...

raman-m commented 11 months ago

Any particular reason it was not giving error in versions 13 but started giving error in version 18

Bob! So... You've upgraded framework from .NET Standard 2.0 to .NET 6, right? Quite a risky upgrade! 🙉

Do you know the fact that in version 16.0.0 release we have a breaking changes aka ReRoutesRoutes renaming introduced by Tom? Sorry, current old release notes don't point to Breaking Changes. So, Ocelot v16- (and lower) apps upgrading will fail. And v13 netstandard2.0 solution in C# code cannot be compatible to v18 net6.0. But I would suggest you to upgrade to .NET 7 and Ocelot v19+ which has (will have) more builds with new features and bugfixes.

Your team should:

Sounds good plan?

ks1990cn commented 10 months ago

Interested, but anything here @bob5296 ?

Probably you can check your serviceName of gateway and downstream is visible at ServiceFabric, to just to verify again its getting registered correctly.

raman-m commented 9 months ago

@bob5296 You don't care, right? Are you ghost? Your repos are empty! 😏

I provided and shared upgrading plan to you on October 6, but you don't care... OK, man... I don't see any sense to keep this issue open.

raman-m commented 9 months ago

The question is answered!