Giter VIP home page Giter VIP logo

Comments (8)

nrllhylmz avatar nrllhylmz commented on June 2, 2024 1

I delete "UpstreamHost":"localhost:6001" and it worked.
I want to use "UpstreamHost"

from ocelot.

nrllhylmz avatar nrllhylmz commented on June 2, 2024 1

Dear @raman-m
I created a sample project for you.


My ocelot.json

{
	"Routes": [
		{
			"UpstreamHost": "localhost:6001",
			"UpstreamPathTemplate": "/test/{everything}",
			"DownstreamPathTemplate": "/{everything}",
			"DownstreamHostAndPorts": [
				{
					"Host": "localhost",
					"Port": 7071
				}
			]
		},
		{
			"UpstreamHost": "localhost:6002",
			"UpstreamPathTemplate": "/test/{everything}",
			"DownstreamPathTemplate": "/{everything}",
			"DownstreamHostAndPorts": [
				{
					"Host": "localhost",
					"Port": 7072
				}
			]
		}
	],
	"GlobalConfiguration": {
		"BaseUrl": "https://localhost:6001"
	}
}

Projects started

Ocelot18.Api(version 18.0.0) => https://localhost:6001;
			 => https://localhost:6002, 
Test1.Api => https://localhost:7071,
Test2.Api => https://localhost:7072

https://localhost:6001/test/WeatherForecast route matched
https://localhost:6002/test/WeatherForecast route matched

Projects stop


Projects started

Ocelot22.Api (version 22.0.1) => https://localhost:6001;
			 => https://localhost:6002, 
Test1.Api => https://localhost:7071,
Test2.Api => https://localhost:7072

https://localhost:6001/test/WeatherForecast route not found
https://localhost:6002/test/WeatherForecast route not found

Projects stop

Repository link: https://github.com/nrllhylmz/Example

Thanks.

from ocelot.

raman-m avatar raman-m commented on June 2, 2024

UpstreamHost not working

Why do you think so? Our unit & acceptance tests are green! 😉


I upgraded ocelot. (18.0.0 -> 22.0.1)

Maybe something wrong with the upgrade process...


Ocelot failed to match routes.

Wow! Please provide more details: ocelot.json file, logs with errors info, and etc.
Which routes? We don't see them! 😉


I deleted this feature. Routes matched. But i want to seperate host(UpstreamHost).

Sorry? What have you deleted and how?

from ocelot.

raman-m avatar raman-m commented on June 2, 2024

@nrllhylmz What's your full name?
Please upload complete solution to your GitHub account for verification and review by our team!

from ocelot.

nrllhylmz avatar nrllhylmz commented on June 2, 2024

Ocelot 18.0.0 working but Ocelot 22.0.1 not working.
Deleted UpstreamHost. Working. But i want to seperate upstreamhost.

Warnings;

requestId: 0HN0MJFAEUU8F:00000009, previousRequestId: No PreviousRequestId, 
message: 'Error Code: UnableToFindDownstreamRouteError 
Message: Failed to match Route configuration for upstream path: /test/WeatherForecast, verb: GET.
errors found in ResponderMiddleware.
Setting error response for request path:/test/WeatherForecast, request method: GET'
 
requestId: 0HN0MJFAEUU8F:00000009, previousRequestId: No PreviousRequestId, 
message: 'DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError 
Message: Failed to match Route configuration for upstream path: /test/WeatherForecast, verb: GET.'

My ocelot.json 👉

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "UpstreamPathTemplate": "/test/{everything}",
      "UpstreamHttpMethod": [
      ],
      "DownstreamHttpMethod": null,
      "AddHeadersToRequest": {
      },
      "UpstreamHeaderTransform": {
      },
      "DownstreamHeaderTransform": {
      },
      "AddClaimsToRequest": {
      },
      "RouteClaimsRequirement": {
      },
      "AddQueriesToRequest": {
      },
      "ChangeDownstreamPathTemplate": {
      },
      "RequestIdKey": null,
     "FileCacheOptions": {
        "TtlSeconds": 0,
        "Region": null
      },
      "RouteIsCaseSensitive": false,
      "ServiceName": null,
      "ServiceNamespace": null,
      "DownstreamScheme": "https",
      "QoSOptions": {
        "ExceptionsAllowedBeforeBreaking": 0,
        "DurationOfBreak": 0,
        "TimeoutValue": 0
      },
      "LoadBalancerOptions": {
        "Type": null,
        "Key": null,
        "Expiry": 0
      },
      "RateLimitOptions": {
        "ClientWhitelist": [
        ],
        "EnableRateLimiting": false,
        "Period": null,
        "PeriodTimespan": 0.0,
        "Limit": 0
      },
      "AuthenticationOptions": {
        "AuthenticationProviderKey": null,
        "AllowedScopes": [
        ]
      },
      "HttpHandlerOptions": {
        "AllowAutoRedirect": false,
        "UseCookieContainer": false,
        "UseTracing": false,
        "UseProxy": true,
        "MaxConnectionsPerServer": 2147483647
      },
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 7071
        }
      ],
      "UpstreamHost": "localhost:6001",
      "Key": null,
      "DelegatingHandlers": [
      ],
      "Priority": 1,
      "Timeout": 0,
      "DangerousAcceptAnyServerCertificateValidator": false,
      "SecurityOptions": {
        "IPAllowedList": [
        ],
        "IPBlockedList": [
        ]
      },
      "DownstreamHttpVersion": null
    }
  ],
  "DynamicRoutes": [
  ],
  "Aggregates": [
  ],
  "GlobalConfiguration": {
    "RequestIdKey": null,
    "ServiceDiscoveryProvider": {
      "Scheme": null,
      "Host": null,
      "Port": 0,
      "Type": null,
      "Token": null,
      "ConfigurationKey": null,
      "PollingInterval": 0,
      "Namespace": null
    },
    "RateLimitOptions": {
      "ClientIdHeader": "ClientId",
      "QuotaExceededMessage": null,
      "RateLimitCounterPrefix": "ocelot",
      "DisableRateLimitHeaders": false,
      "HttpStatusCode": 429
    },
    "QoSOptions": {
      "ExceptionsAllowedBeforeBreaking": 0,
      "DurationOfBreak": 0,
      "TimeoutValue": 0
    },
    "BaseUrl": "https://localhost:6001",
    "LoadBalancerOptions": {
      "Type": null,
      "Key": null,
      "Expiry": 0
    },
    "DownstreamScheme": null,
    "HttpHandlerOptions": {
      "AllowAutoRedirect": false,
      "UseCookieContainer": false,
      "UseTracing": false,
      "UseProxy": true,
      "MaxConnectionsPerServer": 2147483647
    },
    "DownstreamHttpVersion": null
  }
}

from ocelot.

raman-m avatar raman-m commented on June 2, 2024

@nrllhylmz commented on Jan 16:


I delete "UpstreamHost":"localhost:6001" and it worked.
I want to use "UpstreamHost"

But why do you need to use UpstreamHost if you have single route in development environment?
Maybe some firewall tool will help you? 😄

Read UpstreamHost docs and you will get that feature is based on Host header! You just cannot make request from Ocelot instance app to itself!


Your very zipped JSON

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "UpstreamPathTemplate": "/test/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost", "Port": 7071
        }
      ],
      "UpstreamHost": "localhost:6001",
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:6001",
    "DownstreamHttpVersion": null
  }
}

Don't you see the issue?
You cannot use "UpstreamHost" with value localhost:6001 because "BaseUrl" is https://localhost:6001 !!!
You cannot make requests from Ocelot instance to itself!
"UpstreamHost" property is used to filter incoming requests from various domains in DNS form but not from Base URL of Ocelot host & port! It is impossible!
That is why you have error: Failed to match Route configuration for upstream path: /test/WeatherForecast which says that Ocelot cannot find route!

What are you doing? 🤯

from ocelot.

raman-m avatar raman-m commented on June 2, 2024

Nurullah Yılmaz!

I recommend you to

  • start reading Ocelot docs from very beginning.
  • start using DNS and dev & test API tools like Postman

I see misconfiguration problem which should be fixed by your own.
Our all tests are green and UpstreamHost feature should not be broken.
For invalid configs the feature can be broken.

from ocelot.

raman-m avatar raman-m commented on June 2, 2024

Your next created #1926 will be checked by our QA engineer... You can talk to him.

from ocelot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.