如何解决 Spring-cloud-sleuth-zipkin (Edgware.SR5) 中的 RabbitMQ 服务器连接错误
Posted
技术标签:
【中文标题】如何解决 Spring-cloud-sleuth-zipkin (Edgware.SR5) 中的 RabbitMQ 服务器连接错误【英文标题】:How to resolve RabbitMQ Server connection error in Spring-cloud-sleuth-zipkin (Edgware.SR5) 【发布时间】:2019-04-12 00:17:38 【问题描述】:我需要通过 RabbitMQ 将 span 发送到 Zipkin。我正在使用 Spring-Cloud-Sleuth Edgware-SR5 版本和 SpringBoot 1.5.3.RELEASE 版本。 使用较旧的 Spring-cloud sleuth 版本(spring-cloud-stream-binder-rabbit - v1.1.4.RELEASE)它工作正常。
当我尝试启动服务时,我得到“”AsyncReporterRabbitMQSenderaddresses=[localhost:5672], queue=zipkin。无法建立到 RabbitMQ 服务器的连接”错误。 我浏览了文档,但无法解决此问题。
Gradle 配置:
dependencyManagement
imports
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.SR5"
compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-starter-zipkin'
compile 'org.springframework.boot:spring-boot-starter-amqp'
compile 'org.springframework.amqp:spring-rabbit'
Application.yml:
spring:
sleuth:
enabled: true
async:
enabled: true
sampler:
percentage: 1.0
zipkin:
baseUrl:
sender:
type: rabbit
异常堆栈跟踪:
Exception in thread "AsyncReporterRabbitMQSenderaddresses=[localhost:5672], queue=zipkin" java.lang.IllegalStateException: Unable to establish connection to RabbitMQ server
at zipkin2.reporter.amqp.RabbitMQSender.get(RabbitMQSender.java:190)
at zipkin2.reporter.amqp.AutoValue_RabbitMQSender.get(AutoValue_RabbitMQSender.java:27)
at zipkin2.reporter.amqp.RabbitMQSender$1.initialValue(RabbitMQSender.java:211)
at zipkin2.reporter.amqp.RabbitMQSender$1.initialValue(RabbitMQSender.java:208)
at java.lang.ThreadLocal.setInitialValue(Unknown Source)
at java.lang.ThreadLocal.get(Unknown Source)
at zipkin2.reporter.amqp.RabbitMQSender$RabbitMQCall.publish(RabbitMQSender.java:231)
at zipkin2.reporter.amqp.RabbitMQSender$RabbitMQCall.doExecute(RabbitMQSender.java:226)
at zipkin2.reporter.amqp.RabbitMQSender$RabbitMQCall.doExecute(RabbitMQSender.java:218)
at zipkin2.Call$Base.execute(Call.java:379)
at zipkin2.reporter.AsyncReporter$BoundedAsyncReporter.flush(AsyncReporter.java:272)
at zipkin2.reporter.AsyncReporter$Builder$1.run(AsyncReporter.java:179)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create(SocketFrameHandlerFactory.java:50)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:907)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:736)
at zipkin2.reporter.amqp.RabbitMQSender.get(RabbitMQSender.java:188)
感谢和问候 苏雷什
【问题讨论】:
【参考方案1】:
Connection refused: connect
仅表示 RabbitMQ 未在 localhost:5672
上运行(如果您未在 application.yml
中为其提供主机/端口或地址,这是默认设置)。
【讨论】:
以上是关于如何解决 Spring-cloud-sleuth-zipkin (Edgware.SR5) 中的 RabbitMQ 服务器连接错误的主要内容,如果未能解决你的问题,请参考以下文章
spring-cloud-sleuth与spring-amqp集成
将 spring-cloud-sleuth 添加到类路径时出现“上下文初始化”错误
低版本spring-cloud-sleuth的TraceableExecutorService一个坑,注意绕行