未处理的异常。 RabbitMQ.Client.Exceptions.BrokerUnreachableException:指定的端点均不可访问

时间:2020-08-05 02:18:42

标签: docker asp.net-core rabbitmq

我已使用此docker映像在笔记本电脑上设置RabbitMQ服务器。

https://hub.docker.com/_/rabbitmq

和命令:docker run -d --hostname rabbit-release --name rabbit-releaset -p 15672:15672 -p 5672:5672 rabbitmq:3-management

和设置:

"rabbitMq": {
    "namespace": "common",
    "retries": 3,
    "retryInterval": 2,
    "username": "guest",
    "password": "guest",
    "virtualHost": "/",
    "port": 5672,
    "hostnames": [
      "rabbit-release"
    ],
    "requestTimeout": "00:00:10",
    "publishConfirmTimeout": "00:00:01",
    "recoveryInterval": "00:00:10",
    "persistentDeliveryMode": true,
    "autoCloseConnection": true,
    "automaticRecovery": true,
    "topologyRecovery": true,
    "exchange": {
      "durable": true,
      "autoDelete": false,
      "type": "Topic"
    },
    "queue": {
      "autoDelete": false,
      "durable": true,
      "exclusive": false
    }
  },

这是已退出的容器的日志:

未处理的异常。 RabbitMQ.Client.Exceptions.BrokerUnreachableException:无 指定的端点可以访问---> RabbitMQ.Client.Exceptions.ConnectFailureException:连接失败 ---> System.Net.Internals.SocketExceptionFactory + ExtendedSocketException (111):连接在127.0.0.1:5672被拒绝 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception 源)在System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) System.Net.Sockets.Socket。<> c.b__275_0(IAsyncResult Iar) ---从上一个引发异常的位置开始的堆栈跟踪--- RabbitMQ.Client.TcpClientAdapter.ConnectAsync(String 主机,Int32端口)位于 RabbitMQ.Client.Impl.TaskExtensions.TimeoutAfter(任务任务,Int32 毫秒(超时) RabbitMQ.Client.Impl.SocketFrameHandler.ConnectOrFail(ITcpClient 套接字,AmqpTcpEndpoint端点,Int32超时)-内部结束 异常堆栈跟踪--- RabbitMQ.Client.EndpointResolverExtensions.SelectOne [T](IEndpointResolver 解析器,Func 2 selector) at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints) at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) --- End of inner exception stack trace --- at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) at RabbitMQ.Client.ConnectionFactory.CreateConnection(IList 1个主机名, 字符串clientProvidedName)位于 RabbitMQ.Client.ConnectionFactory.CreateConnection(IList 1 hostnames) at RawRabbit.Channel.ChannelFactory.ConnectAsync(CancellationToken token) at RawRabbit.DependencyInjection.RawRabbitDependencyRegisterExtension.<>c.<AddRawRabbit>b__0_3(IDependencyResolver resolver) at RawRabbit.DependencyInjection.SimpleDependencyInjection.<>c__DisplayClass4_0 2.b__0() 在System.Lazy 1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy 1.ExecutionAndPublication(LazyHelper executionAndPublication,布尔值useDefaultConstructor) System.Lazy 1.CreateValue() at System.Lazy 1.get_Value()位于 RawRabbit.DependencyInjection.SimpleDependencyInjection。<> c__DisplayClass4_0 2.<AddSingleton>b__1(IDependencyResolver resolver) at RawRabbit.DependencyInjection.SimpleDependencyInjection.GetService(Type serviceType, Object[] additional) at RawRabbit.DependencyInjection.SimpleDependencyInjection.GetService[TService](Object[] additional) at RawRabbit.Instantiation.InstanceFactory.Create() at iNRES.Common.RabbitMq.Extensions.AddRabbitMq(IServiceCollection services, IConfiguration configuration) at iNRES.Service.Common.Startup.ConfigureServices(IServiceCollection services) in /app/src/iNRES.Service.Common/Startup.cs:line 116 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.<Invoke>g__Startup|0(IServiceCollection serviceCollection) at Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder 1。<> c__DisplayClass15_0.g__RunPipeline | 0(IServiceCollection 服务) Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(对象 例如IServiceCollection服务) Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder。<> c__DisplayClass8_0.b__0(IServiceCollection 服务) Microsoft.AspNetCore.Hosting.StartupLoader.ConfigureServicesDelegateBuilder`1。<> c__DisplayClass14_0.g__ConfigureServicesWithContainerConfiguration | 0(IServiceCollection 服务) Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection 服务) Microsoft.AspNetCore.Hosting.WebHost.EnsureApplicationServices()在 Microsoft.AspNetCore.Hosting.WebHost.Initialize()在 Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()在 iNRES.Service.WaterResource.Program.Main(String [] args)在 /app/src/iNRES.Service.Common/Program.cs:line 18

1 个答案:

答案 0 :(得分:0)

如果您正在主机中运行客户端代码,则--hostname docker选项无效,因此您需要在客户端代码中使用localhost而不是rabbit-release