rabbitmq vhost /test not found

在尝试使用RabbitMQ建立连接时遇到了IOException,具体表现为AMQChannel的wrap方法抛出异常,导致ShutdownSignalException,原因是连接错误,协议方法显示不允许操作(NOT_ALLOWED)。此外,还发生了NullPointerException,在主线程中。这可能是由于RabbitMQ的连接配置问题,如虚拟主机不存在或配置错误所导致。

java.io.IOException
	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129)
	at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125)
	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147)
	at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:423)
	at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:64)
	at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:156)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1110)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1067)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1025)
	at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1187)
	at rabbit2.RabbitMqUtil.getConn(RabbitMqUtil.java:33)
	at rabbit5.Task.main(Task.java:14)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - vhost /test not found, class-id=10, method-id=40)
	at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66)
	at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36)
	at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502)
	at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:293)
	at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:141)
	... 9 more
Exception in thread "main" java.lang.NullPointerException
	at rabbit5.Task.main(Task.java:17)
11:57:48.451 [AMQP Connection 192.168.1.3:5673] ERROR com.rabbitmq.client.impl.ForgivingExceptionHandler - An unexpected connection driver error occured
java.net.SocketException: socket closed
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
	at java.net.SocketInputStream.read(SocketInputStream.java:171)
	at java.net.SocketInputStream.read(SocketInputStream.java:141)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:265)
	at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288)
	at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91)
	at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:184)
	at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:645)
	at java.lang.Thread.run(Thread.java:748)

=======

2025-06-04 07:51:59.087849+00:00 [error] <0.9162.2> Error on AMQP connection <0.9162.2> (192.168.150.1:58853 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3934, user: 'tjxt', state: opening): 2025-06-04 07:51:59.087849+00:00 [error] <0.9162.2> vhost /tjxt not found 2025-06-04 07:51:59.087951+00:00 [error] <0.9165.2> Error on AMQP connection <0.9165.2> (192.168.150.1:58854 -> 172.21.0.7:5672 - rabbitConnectionFactory#5a8149f6:2424, user: 'tjxt', state: opening): 2025-06-04 07:51:59.087951+00:00 [error] <0.9165.2> vhost /tjxt not found 2025-06-04 07:51:59.088552+00:00 [info] <0.9162.2> closing AMQP connection <0.9162.2> (192.168.150.1:58853 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3934, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.088591+00:00 [info] <0.9165.2> closing AMQP connection <0.9165.2> (192.168.150.1:58854 -> 172.21.0.7:5672 - rabbitConnectionFactory#5a8149f6:2424, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.090987+00:00 [info] <0.9178.2> accepting AMQP connection <0.9178.2> (192.168.150.1:58856 -> 172.21.0.7:5672) 2025-06-04 07:51:59.092844+00:00 [info] <0.9178.2> Connection <0.9178.2> (192.168.150.1:58856 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3935 2025-06-04 07:51:59.093760+00:00 [error] <0.9178.2> Error on AMQP connection <0.9178.2> (192.168.150.1:58856 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3935, user: 'tjxt', state: opening): 2025-06-04 07:51:59.093760+00:00 [error] <0.9178.2> vhost /tjxt not found 2025-06-04 07:51:59.094560+00:00 [info] <0.9178.2> closing AMQP connection <0.9178.2> (192.168.150.1:58856 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3935, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.173739+00:00 [info] <0.9186.2> accepting AMQP connection <0.9186.2> (192.168.150.1:58858 -> 172.21.0.7:5672) 2025-06-04 07:51:59.175441+00:00 [info] <0.9186.2> Connection <0.9186.2> (192.168.150.1:58858 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3936 2025-06-04 07:51:59.176284+00:00 [error] <0.9186.2> Error on AMQP connection <0.9186.2> (192.168.150.1:58858 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3936, user: 'tjxt', state: opening): 2025-06-04 07:51:59.176284+00:00 [error] <0.9186.2> vhost /tjxt not found 2025-06-04 07:51:59.177442+00:00 [info] <0.9186.2> closing AMQP connection <0.9186.2> (192.168.150.1:58858 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3936, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.179772+00:00 [info] <0.9194.2> accepting AMQP connection <0.9194.2> (192.168.150.1:58860 -> 172.21.0.7:5672) 2025-06-04 07:51:59.208946+00:00 [info] <0.9194.2> Connection <0.9194.2> (192.168.150.1:58860 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3937 2025-06-04 07:51:59.218862+00:00 [error] <0.9194.2> Error on AMQP connection <0.9194.2> (192.168.150.1:58860 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3937, user: 'tjxt', state: opening): 2025-06-04 07:51:59.218862+00:00 [error] <0.9194.2> vhost /tjxt not found 2025-06-04 07:51:59.228782+00:00 [info] <0.9194.2> closing AMQP connection <0.9194.2> (192.168.150.1:58860 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3937, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.231093+00:00 [info] <0.9202.2> accepting AMQP connection <0.9202.2> (192.168.150.1:58864 -> 172.21.0.7:5672) 2025-06-04 07:51:59.232076+00:00 [info] <0.9202.2> Connection <0.9202.2> (192.168.150.1:58864 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3938 2025-06-04 07:51:59.232615+00:00 [error] <0.9202.2> Error on AMQP connection <0.9202.2> (192.168.150.1:58864 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3938, user: 'tjxt', state: opening): 2025-06-04 07:51:59.232615+00:00 [error] <0.9202.2> vhost /tjxt not found 2025-06-04 07:51:59.239051+00:00 [info] <0.9208.2> accepting AMQP connection <0.9208.2> (192.168.150.1:58866 -> 172.21.0.7:5672) 2025-06-04 07:51:59.248761+00:00 [info] <0.9202.2> closing AMQP connection <0.9202.2> (192.168.150.1:58864 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3938, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.248846+00:00 [info] <0.9208.2> Connection <0.9208.2> (192.168.150.1:58866 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3939 2025-06-04 07:51:59.253316+00:00 [error] <0.9208.2> Error on AMQP connection <0.9208.2> (192.168.150.1:58866 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3939, user: 'tjxt', state: opening): 2025-06-04 07:51:59.253316+00:00 [error] <0.9208.2> vhost /tjxt not found 2025-06-04 07:51:59.254859+00:00 [info] <0.9208.2> closing AMQP connection <0.9208.2> (192.168.150.1:58866 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3939, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.256543+00:00 [info] <0.9218.2> accepting AMQP connection <0.9218.2> (192.168.150.1:58868 -> 172.21.0.7:5672) 2025-06-04 07:51:59.257247+00:00 [info] <0.9218.2> Connection <0.9218.2> (192.168.150.1:58868 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3940 2025-06-04 07:51:59.257664+00:00 [error] <0.9218.2> Error on AMQP connection <0.9218.2> (192.168.150.1:58868 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3940, user: 'tjxt', state: opening): 2025-06-04 07:51:59.257664+00:00 [error] <0.9218.2> vhost /tjxt not found 2025-06-04 07:51:59.258960+00:00 [info] <0.9218.2> closing AMQP connection <0.9218.2> (192.168.150.1:58868 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3940, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.264548+00:00 [info] <0.9226.2> accepting AMQP connection <0.9226.2> (192.168.150.1:58870 -> 172.21.0.7:5672) 2025-06-04 07:51:59.266612+00:00 [info] <0.9226.2> Connection <0.9226.2> (192.168.150.1:58870 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3941 2025-06-04 07:51:59.267287+00:00 [error] <0.9226.2> Error on AMQP connection <0.9226.2> (192.168.150.1:58870 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3941, user: 'tjxt', state: opening): 2025-06-04 07:51:59.267287+00:00 [error] <0.9226.2> vhost /tjxt not found 2025-06-04 07:51:59.267928+00:00 [info] <0.9226.2> closing AMQP connection <0.9226.2> (192.168.150.1:58870 -> 172.21.0.7:5672 - rabbitConnectionFactory#700596f9:3941, vhost: 'none', user: 'tjxt') 2025-06-04 07:51:59.285898+00:00 [info] <0.9234.2> accepting AMQP connection <0.9234.2> (192.168.150.1:58872 -> 172.21.0.7:5672) 2025-06-04 07:51:59.286718+00:00 [info] <0.9234.2> Connection <0.9234.2> (192.168.150.1:58872 -> 172.21.0.7:5672) has a client-provided name: rabbitConnectionFactory#700596f9:3942 2025-06-04 07:51:59.287088+00:00 [error] <0.9234.2> Error on AMQP connection <0.9234.2> (192.168.150^C
06-28
### 关于 RabbitMQ Virtual Host 配置 RabbitMQ 中的虚拟主机(Virtual Host, vhost)用于隔离不同的消息队列环境,类似于 Web 服务器中的虚拟主机概念。每个 vhost 拥有独立的消息队列、交换器和其他资源。 #### 虚拟主机配置路径 RabbitMQ 的虚拟主机可以通过管理插件或命令行工具进行管理和配置。默认情况下,`/` 是唯一的虚拟主机,在安装完成后自动创建[^1]。如果需要自定义虚拟主机名称(例如 `/v`),可以按照以下方式进行操作: #### 创建虚拟主机 通过 `rabbitmqctl` 命令创建新的虚拟主机: ```bash sudo rabbitmqctl add_vhost /v ``` 此命令会在 RabbitMQ 中新增名为 `/v` 的虚拟主机。 #### 用户权限分配 为了使特定用户能够访问新创建的虚拟主机 `/v`,需为其设置相应的权限: ```bash sudo rabbitmqctl set_permissions -p /v username ".*" ".*" ".*" ``` 上述命令中 `-p /v` 表示针对虚拟主机 `/v` 设置权限;`username` 替换为目标用户名;三个正则表达式分别对应配置、写入和读取权限[^2]。 #### 配置文件中的虚拟主机设定 虽然 RabbitMQ 不直接在配置文件中指定虚拟主机名,但可以在 `rabbitmq.conf` 文件中调整与虚拟主机相关的参数。例如,修改日志记录行为以区分不同虚拟主机的日志输出: ```ini log.vhosts = true ``` 这会为每个虚拟主机生成单独的日志文件[^3]。 #### 访问控制与安全 当启用了管理插件后,可通过浏览器访问 RabbitMQ 管理界面来查看和管理虚拟主机及其相关内容。确保管理插件监听的 IP 地址和端口号已正确配置,以便外部设备能正常连接至目标虚拟主机。例如,默认管理插件的 HTTP 监听端口为 15672,可按如下方式更改: ```ini management.tcp.port = 15680 management.tcp.ip = 127.0.0.1 ``` 以上配置允许仅本地机器通过端口 15680 进行管理界面访问。 ### 总结 对于 RabbitMQ 的虚拟主机 `/v` 或其他自定义命名空间的相关配置,主要涉及其创建、用户权限绑定以及可能的安全性和性能优化选项。这些都可以借助官方文档进一步深入学习。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

13805029595

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值