gpt4 book ai didi

linux - 在 Docker 中运行 RabbitMQ 服务器

转载 作者:太空狗 更新时间:2023-10-29 11:07:28 26 4
gpt4 key购买 nike

我在连接到 vanilla RabbitMQ Docker 容器时收到 EOFException。日志目录为空/var/log/rabbitmq 不包含任何文件。 Web 控制台工作没有问题。它只是连接到它不起作用。

因为这是来自 Docker Hub 的普通容器,我想是我遗漏了一些基本的东西。但是什么? :-)

还有什么我可以检查的吗?


创建容器的命令:

sudo docker run -d --hostname konijn --name konijn -p 5672:5762 -p 5671:5671 -p 15672:15672 rabbitmq:3.6.6-management

它显示为正在运行:

$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a62c2635d17 rabbitmq:3.6.6-management "docker-entrypoint.sh" 12 seconds ago Up 10 seconds 4369/tcp, 5672/tcp, 0.0.0.0:5671->5671/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, 0.0.0.0:5672->5762/tcp konijn

运行此代码示例时:

  @Test
public void testUnprotectedConnection() throws Exception {
final ConnectionFactory factory = new ConnectionFactory();
factory.setUri("amqp://guest:guest@localhost:5672/");
Connection conn = factory.newConnection();
}

我得到:

java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:105)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:101)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:353)
at com.rabbitmq.client.impl.recovery.RecoveryAwareAMQConnectionFactory.newConnection(RecoveryAwareAMQConnectionFactory.java:62)
at com.rabbitmq.client.impl.recovery.AutorecoveringConnection.init(AutorecoveringConnection.java:99)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:900)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:859)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:817)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:954)
at com.enervalis.messaging.rabbitmq.RabbitMQCertificateTest.testUnprotectedConnection(RabbitMQCertificateTest.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:377)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error
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:372)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:297)
... 30 more
Caused by: java.io.EOFException
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290)
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:91)
at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:164)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:571)
... 1 more

容器的日志文件丢失:

$ sudo docker exec konijn ls -l /var/log/rabbitmq
total 0

docker版本信息:

$ sudo docker version
Client:
Version: 1.13.0
API version: 1.25
Go version: go1.7.3
Git commit: 49bf474
Built: Tue Jan 17 10:05:19 2017
OS/Arch: linux/amd64

Server:
Version: 1.13.0
API version: 1.25 (minimum version 1.12)
Go version: go1.7.3
Git commit: 49bf474
Built: Tue Jan 17 10:05:19 2017
OS/Arch: linux/amd64
Experimental: false

系统信息:

XUbuntu 16.10, amd64

$ uname -a
Linux black 4.8.0-34-generic #36-Ubuntu SMP Wed Dec 21 17:24:18 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/issue
Ubuntu 16.10

最佳答案

您正在公开 5672:5762 端口。容器内部端口为5762,而RabbitMQ默认端口为5672。

关于linux - 在 Docker 中运行 RabbitMQ 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41935363/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com