- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 docker-compose 从 docker 内部连接到 rabbitMQ。从容器外运行的程序连接到“image:rabbitmq:3-management”没有问题。
没有设置密码或任何东西。
在查看更多错误消息后,似乎 pika 尝试使用 IPv6 而不是 IPv4 连接。查看文档,我想不出连接 IPv4 的方法。
失败发生在
self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
Error log
rabbitMQ_1 | 2020-12-09 12:41:42.332 [info] <0.685.0> Ready to start client connection listeners
rabbitMQ_1 | 2020-12-09 12:41:42.333 [info] <0.988.0> started TCP listener on [::]:5672
listener_1 | ERROR:pika.adapters.utils.io_services_utils:Socket failed to connect: <socket.socket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 36782)>; error=111 (Connection refused)
listener_1 | ERROR:pika.adapters.utils.connection_workflow:TCP Connection attempt failed: ConnectionRefusedError(111, 'Connection refused'); dest=(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 5672))
listener_1 | ERROR:pika.adapters.utils.connection_workflow:AMQPConnector - reporting failure: AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused')
listener_1 | ERROR:pika.adapters.utils.io_services_utils:<socket.socket fd=9, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=6, laddr=('::', 0, 0, 0)>.connect(('::1', 5672, 0, 0)) failed: OSError(99, 'Cannot assign requested address')
listener_1 | ERROR:pika.adapters.utils.connection_workflow:TCP Connection attempt failed: OSError(99, 'Cannot assign requested address'); dest=(<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('::1', 5672, 0, 0))
listener_1 | ERROR:pika.adapters.utils.connection_workflow:AMQPConnector - reporting failure: AMQPConnectorSocketConnectError: OSError(99, 'Cannot assign requested address')
listener_1 | ERROR:pika.adapters.utils.connection_workflow:AMQP connection workflow failed: AMQPConnectionWorkflowFailed: 2 exceptions in all; last exception - AMQPConnectorSocketConnectError: OSError(99, 'Cannot assign requested address'); first exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused').
listener_1 | ERROR:pika.adapters.utils.connection_workflow:AMQPConnectionWorkflow - reporting failure: AMQPConnectionWorkflowFailed: 2 exceptions in all; last exception - AMQPConnectorSocketConnectError: OSError(99, 'Cannot assign requested address'); first exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused')
listener_1 | ERROR:pika.adapters.blocking_connection:Connection workflow failed: AMQPConnectionWorkflowFailed: 2 exceptions in all; last exception - AMQPConnectorSocketConnectError: OSError(99, 'Cannot assign requested address'); first exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused')
listener_1 | ERROR:pika.adapters.blocking_connection:Error in _create_connection().
listener_1 | Traceback (most recent call last):
listener_1 | File "/usr/local/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
listener_1 | raise self._reap_last_connection_workflow_error(error)
listener_1 | pika.exceptions.AMQPConnectionError
docker-compose.yml
version: '3'
services:
rabbitMQ:
image: rabbitmq:3-management
ports:
- "15672:15672"
- "5672:5672"
login:
build:
context: .
dockerfile: Dockerfile.login
restart: on-failure
listener:
build:
context: .
dockerfile: Dockerfile.listener
restart: on-failure
最佳答案
docker-compose 没有设置本地主机网络。这意味着每个服务都有自己的名称。在这种情况下,应该更改主机。
self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
should be changed to
self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='rabbitMQ'))
关于Docker、rabbitMQ 和 pike 连接被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65217124/
我正在尝试使用 docker-compose 从 docker 内部连接到 rabbitMQ。从容器外运行的程序连接到“image:rabbitmq:3-management”没有问题。 没有设置
什么是 c# 正则表达式来替换开始和结束派克之间的所有文本/字符? 例如: this is an that to turn into => this is an that to turn into
在 Rob Pike 的 2012 年演讲中,Concurrency is not Parallelism (it's better) ,他有一个正在运行的例子,说明一群 gophers 一起工作来焚
配置: Openstack Pike 在 Ubuntu16.04 VM 上使用 devStack 启用插件: 撒哈拉 热火 珍宝 撒哈拉仪表板 Trove 仪表板 安装成功,可以访问horizon
这是从“Google I/O 2012 - Go Concurrency Patterns”(slides)中获取的代码示例 package main import ( "fmt" "
我是一名优秀的程序员,十分优秀!