Hi All,
I am implementing my first docker project with ocelot api gateway and i am using asp.net core 2.2 to develop api's. so everything works fine on my local machine when using docker-compose command to run the container.
But when i push my images to docker hub and then pulling back those images from there my gateway api not responding and getting 500 internal server error in postman but when i hit another api servicea form postman i am getting 401 unauthorised status code.
I don't whats going wrong . Please help me
here is my ocelot config
{
"ReRoutes": [
{
"DownstreamPathTemplate": "/api/abc/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "nst.xxx.abcapi",
"Port": 80
}
],
"UpstreamPathTemplate": "/abc/{everything}",
"UpstreamHttpMethod": [],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Test.Key",
"AllowedScopes": []
}
},
{
"DownstreamPathTemplate": "/api/xyz/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "nst.xxx.xyzapi",
"Port": 80
}
],
"UpstreamPathTemplate": "/xyz/{everything}",
"UpstreamHttpMethod": [],
"AuthenticationOptions": {
"AuthenticationProviderKey": "Test.Key",
"AllowedScopes": []
}
},
{
"DownstreamPathTemplate": "/api/auth/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "nst.xxx.tokenapi",
"Port": 80
}
],
"UpstreamPathTemplate": "/auth/{everything}",
"UpstreamHttpMethod": []
},
],
"GlobalConfiguration": {
"RequestIdKey": "OcRequestId",
"AdministrationPath": "/administration"
}
}
and when i inspect the docker container logs then here is the response ๐
Ocelot.Requester.Middleware.HttpRequesterMiddleware[0]
requestId: 0HLNRILO35FS1:00000004, previousRequestId: no previous request id, message: Error making http request, exception: System.Net.Http.HttpRequestException: No such host is known ---> System.Net.Sockets.SocketException: No such host is known
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask
1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask) at System.Threading.Tasks.ValueTask
1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) at Ocelot.Requester.HttpClientHttpRequester.GetResponse(DownstreamContext context) warn: Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId: 0HLNRILO35FS1:00000004, previousRequestId: no previous request id, message: Error Code: UnableToCompleteRequestError Message: Error making http request, exception: System.Net.Http.HttpRequestException: No such host is known ---> System.Net.Sockets.SocketException: No such host is known at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask
1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask
1 creationTask)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task
1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Ocelot.Requester.HttpClientHttpRequester.GetResponse(DownstreamContext context) errors found in ResponderMiddleware. Setting error response for request path:/auth/token, request method: POST
Thanks
Anil