I initially set up this repo as two containers, one serving a dotnetcore webapi, and the other a dotnetcore console app that hit the webapi. They were both on the same docker network, and everything worked smoothly, hitting the webapi using the container name in the URL.
Then I added RabbitMQ as another container, and while I am able to hit the rabbit-mgmt console in my web browser, I cannot hit Rabbit from the webAPI app. See error message below.
I uploaded the code base to github (link below). Any idea what I'm doing wrong? Something in docker compose, or something in MessageService.cs? I'm pasting the error below also, but I think the issue is that the MessageService cannot reach the rabbitMQ container. Any help would be greatly appreciated.
https://github.com/matthew-harper/rabbit-docker-sample
publisher_api_1 | fail: Microsoft.AspNetCore.Server.Kestrel[13]
publisher_api_1 | Connection id "0HLNPLL1QJORV", Request id "0HLNPLL1QJORV:00000001": An unhandled exception was thrown by the application.
publisher_api_1 | RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.AggregateException: One or more errors occurred. (Connection failed) ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address
publisher_api_1 | at System.Net.Dns.InternalGetHostByName(String hostName)
publisher_api_1 | at System.Net.Dns.ResolveCallback(Object context)
publisher_api_1 | --- End of stack trace from previous location where exception was thrown --