Ocelot
Ocelot copied to clipboard
HEAD warning about hostname could not be parsed
Actual Behavior / Motivation for New Feature
see this warning: warn: Ocelot.Request.Middleware.DownstreamRequestInitialiserMiddleware[0] requestId: 0HLV2RDUF49SO:00000001, previousRequestId: no previous request id, message: Error when parsing incoming request, exception: System.UriFormatException: Invalid URI: The hostname could not be parsed. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at Ocelot.Request.Mapper.RequestMapper.Map(HttpRequest request, DownstreamReRoute downstreamReRoute)
a bunch of times in log, can I solve this issue or should I just ignore it and if then can I setup to ignore this error so it does not come to log ?
Steps to Reproduce the Problem
- We have a route: { "DownstreamPathTemplate": "/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "${PORTAL_API_HOST}", "Port": ${PORTAL_API_PORT} } ], "UpstreamPathTemplate": "/{everything}", "UpstreamHttpMethod": [ "GET", "POST","PUT","HEAD" ] }
Specifications
- Version:14.0.11
- Platform: linux
- Subsystem:
Hi
Any updates on this?
Hi,
I am facing the same issue. Did you find any solution?
Hi, Sorry no, and still no answer on this...
Hello,
Im coming from the future. After 2 years the problem won
t be fixed. ;d I have it too : (
Hi All,
First time using Ocelot so don't judge my silly mistake, I had this same error but in my case it simply came down to the port setup, hope this helps someone:
Incorrect DownstreamHostAndPorts
:
"DownstreamHostAndPorts": [ { "Host": "localhost:7178", "Port": 443 } ]
Correct DownstreamHostAndPorts
:
"DownstreamHostAndPorts": [ { "Host": "localhost", "Port": 7178 } ],
As you can see, the error simply came down to the double inclusion of the ports which resulted in an invalid URI "localhost:7178:443".
Cheers
@mejsin
1
"Host": "${PORTAL_API_HOST}",
"Port": "${PORTAL_API_PORT}"
2
System.UriFormatException: Invalid URI: The hostname could not be parsed.
Conclusion
You can't use in-place placeholders of strange format, because Ocelot doesn't support them! You must pre-process your template file by a script and replace placeholders with correct values :exclamation:
Misconfiguration issue and invalid route definition!