本文介绍了由于 SocketException,RabbitMQ 新连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建与在不同服务器上运行的 rabbitmq 的新连接时,出现以下错误:

java.io.IOException在 com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)在 com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)在 com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)在 com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:406)在 com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:516)在 com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:533)引起:com.rabbitmq.client.ShutdownSignalException:连接错误;原因:java.net.SocketException:连接重置在 com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)在 com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)在 com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)在 com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)在 com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)引起:java.net.SocketException:连接重置在 java.net.SocketInputStream.read(Unknown Source)在 java.net.SocketInputStream.read(Unknown Source)在 java.io.BufferedInputStream.fill(Unknown Source)在 java.io.BufferedInputStream.read(Unknown Source)在 java.io.DataInputStream.readUnsignedByte(Unknown Source)在 com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)在 com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:131)在 com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533)

采取的步骤:

  • rabbitmq 正在服务器上运行.
  • 指定服务器
  • 指定了默认端口

lsof -i tcp:5672

命令 PID 用户 FD 类型设备大小/关闭节点名称

beam.smp 3084 rabbitmq 15u IPv6 18611 0t0 TCP *:amqp(听)

rabbitmqctl list_connections

列出连接...来宾客户端服务器 55765 正在运行...完成.

netstat -tapnl |grep 5672

tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 3084/beam.smp

tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 3084/beam.smp

tcp 0 0 :::5672 :::* LISTEN 3084/beam.smp

解决方案

可能的原因之一是您连接到 RabbitMQ 的用户没有访问虚拟主机的权限.

您可以使用管理插件(管理"选项卡)进行检查.

while trying to create a new connection to rabbitmq running on a different server, I got the following error:

java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:406)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:516)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:533)


Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.net.SocketException: Connection reset


at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)



Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readUnsignedByte(Unknown Source)
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)
at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:131)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533)


  • rabbitmq is running on the server.
  • server is specified
  • default port is specified

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

beam.smp 3084 rabbitmq 15u IPv6 18611 0t0 TCP *:amqp (LISTEN)

Listing connections ...guest client_server 55765 running...done.

tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 3084/beam.smp

tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 3084/beam.smp

tcp 0 0 :::5672 :::* LISTEN 3084/beam.smp

解决方案

One of the possible reasons is that user you are connecting with to RabbitMQ has no rights to access to virtual hosts.

You can check this using Management Plugin (Admin tab).

这篇关于由于 SocketException,RabbitMQ 新连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 01:22