Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MassTransit RabbitMQ连接立即断开_C#_Docker_Rabbitmq_Masstransit - Fatal编程技术网

C# MassTransit RabbitMQ连接立即断开

C# MassTransit RabbitMQ连接立即断开,c#,docker,rabbitmq,masstransit,C#,Docker,Rabbitmq,Masstransit,我正在使用MassTransit和RabbitMQ建立一个项目。我从一个docker compose.yml文件中调出RabbitMQ和我的映像,但是我的映像连接了,然后立即断开连接,没有出现非常有用的错误消息 我在谷歌上搜索了一下,到目前为止都没有成功。如果有人能给我指点,我将不胜感激 公共交通系统初始化: IBusControl CreateBus(IServiceProvider serviceProvider) {

我正在使用MassTransit和RabbitMQ建立一个项目。我从一个
docker compose.yml
文件中调出RabbitMQ和我的映像,但是我的映像连接了,然后立即断开连接,没有出现非常有用的错误消息

我在谷歌上搜索了一下,到目前为止都没有成功。如果有人能给我指点,我将不胜感激

公共交通系统初始化:

            IBusControl CreateBus(IServiceProvider serviceProvider)
            {
                return Bus.Factory.CreateUsingRabbitMq(cfg => {
                cfg.Host("rabbitmq", h => {
                    h.Username("guest");
                    h.Password("guest");
                    });
                });
            }

            services.AddMassTransit(CreateBus);
docker-compose.yml:

version: "2"

services:
  rabbit:
    hostname: rabbit
    image: rabbitmq:3-management
    environment:
      - RABBITMQ_DEFAULT_USER=guest
      - RABBITMQ_DEFAULT_PASS=guest
    ports:
      - 5672:5672
      - 15672:15672

  my-cool-api:
    build:
      context: .
      dockerfile: ./Dockerfile
    image: my-cool-api
    container_name: my-cool-api
    hostname: my-cool-api
    ports:
      - 1070:80
    environment:
      - RabbitMq:Hostname=rabbit
    depends_on:
      - rabbit
错误堆栈跟踪:

rabbit_1       | 2020-01-20 16:22:02.040 [info] <0.570.0> accepting AMQP connection <0.570.0> (172.22.0.3:34100 -> 172.22.0.2:5672)
rabbit_1       | 2020-01-20 16:22:02.053 [info] <0.570.0> Connection <0.570.0> (172.22.0.3:34100 -> 172.22.0.2:5672) has a client-provided name: dotnet
rabbit_1       | 2020-01-20 16:22:02.056 [info] <0.570.0> connection <0.570.0> (172.22.0.3:34100 -> 172.22.0.2:5672 - dotnet): user 'guest' authenticated and granted access to vhost '/'
rabbit_1       | 2020-01-20 16:22:02.081 [info] <0.570.0> closing AMQP connection <0.570.0> (172.22.0.3:34100 -> 172.22.0.2:5672 - dotnet, vhost: '/', user: 'guest')
my-cool-api    | Unhandled exception. System.AggregateException: One or more errors occurred. (One or more errors occurred. (Broker unreachable: guest@rabbit:5672/))
my-cool-api    |  ---> System.AggregateException: One or more errors occurred. (Broker unreachable: guest@rabbit:5672/)
my-cool-api    |  ---> MassTransit.RabbitMqTransport.RabbitMqConnectionException: Broker unreachable: guest@rabbit:5672/
my-cool-api    |  ---> RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
my-cool-api    |  ---> System.AggregateException: One or more errors occurred. (Connection failed)
my-cool-api    |  ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed
my-cool-api    |  ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (111): Connection refused 172.22.0.2:5672
my-cool-api    |    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
my-cool-api    |    at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
my-cool-api    |    at System.Net.Sockets.Socket.<>c.<ConnectAsync>b__275_0(IAsyncResult iar)
my-cool-api    | --- End of stack trace from previous location where exception was thrown ---
my-cool-api    |    at RabbitMQ.Client.TcpClientAdapter.ConnectAsync(String host, Int32 port)
my-cool-api    |    at RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(Task task, Int32 millisecondsTimeout)
my-cool-api    |    at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
my-cool-api    |    --- End of inner exception stack trace ---
my-cool-api    |    at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout, AddressFamily family)
my-cool-api    |    at RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 timeout)
my-cool-api    |    at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
my-cool-api    |    at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func`2 socketFactory, Int32 connectionTimeout, Int32 readTimeout, Int32 writeTimeout)
...
rabbit_1 | 2020-01-20 16:22:02.040[信息]接受AMQP连接(172.22.0.3:34100->172.22.0.2:5672)
rabbit|1 | 2020-01-20 16:22:02.053[信息]连接(172.22.0.3:34100->172.22.0.2:5672)具有客户端提供的名称:dotnet
rabbit|1 | 2020-01-20 16:22:02.056[信息]连接(172.22.0.3:34100->172.22.0.2:5672-dotnet):用户“来宾”已通过身份验证并被授予访问vhost“/”的权限
rabbit|1 | 2020-01-20 16:22:02.081[信息]正在关闭AMQP连接(172.22.0.3:34100->172.22.0.2:5672-dotnet,vhost:“/”,用户:“guest”)
我的酷api |未处理的异常。System.AggregateException:发生一个或多个错误。(发生一个或多个错误。(无法访问代理:guest@rabbit:5672/))
my cool api |-->System.AggregateException:发生了一个或多个错误。(经纪人无法联系:guest@rabbit:5672/)
my cool api |-->MassTransit.RabbitMqTransport.RabbitMqConnectionException:代理无法访问:guest@rabbit:5672/
my cool api |-->RabbitMQ.Client.Exceptions.BrokerRunReachableException:指定的终结点都不可访问
my cool api |-->System.AggregateException:发生了一个或多个错误。(连接失败)
my cool api |-->RabbitMQ.Client.Exceptions.ConnectFailureException:连接失败
my cool api |-->System.Net.Internal.SocketExceptionFactory+ExtendedSocketException(111):连接被拒绝172.22.0.2:5672
my cool api | at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(异常源)
我的酷api |位于System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
我的酷api |位于System.Net.Sockets.Socket.c.b_uu275_u0(IAsyncResult iar)
my cool api |---来自引发异常的前一个位置的堆栈结束跟踪---
RabbitMQ.Client.TcpClientAdapter.ConnectAsync(字符串主机,Int32端口)上的我的酷api
RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(任务任务,Int32毫秒计时)上的我的酷api
RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient套接字、AmqpTcpEndpoint端点、Int32超时)上的我的酷api
我的酷api——内部异常堆栈跟踪的结束---
RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingAddressFamily(AmqpTcpEndpoint端点,Func`2 socketFactory,Int32超时,AddressFamily)上的我的酷api
RabbitMQ.Client.Impl.SocketFrameHandler.ConnectUsingIPv4(AmqpTcpEndpoint端点,Func`2 socketFactory,Int32超时)上的我的酷api
RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint端点、Func`2 socketFactory、Int32 connectionTimeout、Int32 readTimeout、Int32 writeTimeout)上我的酷api
RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol协议、AmqpTcpEndpoint端点、Func`2 socketFactory、Int32 connectionTimeout、Int32 readTimeout、Int32 writeTimeout)上的我的酷api
...

连接被拒绝172.22.0.2:5672
-要么RabbitMQ没有真正运行,要么是网络问题阻止了连接(防火墙、端口转发等)。
连接被拒绝172.22.0.2:5672
-要么RabbitMQ没有真正运行,要么是网络问题阻止了连接(防火墙、端口转发等)。