我无法连接到Rabbitmq服务器端口5672
用这个命令
php bin/console rabbitmq:consumer -w upload_picture
我有这个问题。
[ErrorException] stream_socket_client(): unable to connect to tcp://localhost:5672 (Aucune connexion n'a pu etre établie car l'ordinateur cible lÆa expressÚment refusée.
所以我无法连接到服务器rabbitmq
config.yml
old_sound_rabbit_mq: connections: default: host: 'localhost' # hostname and port of the rabbitmq server port: 5672 user: 'guest' password: 'guest' vhost: '/' lazy: true # a lazy connection avoids unnecessary connections to the broker on every request connection_timeout: 3 read_write_timeout: 3 keepalive: false heartbeat: 0 producers: upload_picture: connection: default # connects to the default connection configured above exchange_options: {name: 'upload_picture', type: direct} consumers: upload_picture: connection: default # connects to the default connection configured above exchange_options: {name: 'upload_picture', type: direct} queue_options: {name: 'upload_picture'} callback: upload_picture_service # the UploadPictureConsumer defined below
根据你的评论
7c01193b2f74 projecttest_queue "docker-entrypoint..." 24 hours ago Up 5 hours 4369/tcp, 5671/tcp, 25672/tcp, 0.0.0.0:55672->5672/tcp, 0.0.0.0:32768->15672/tcp
该项目正在侦听的端口是55672 – 请参阅0.0.0.0:55672->5672/tcp
5627 / 0.0.0.0:55672->5672/tcp
因此,您需要更新您的PHP项目连接到localhost:55672
而不是只是localhost:5672
你可以直接find你需要连接的端口
docker inspect --format '{{ (index (index .NetworkSettings.Ports "5672/tcp") 0).HostPort }}' rabbitmq_container
请参阅如何在执行Docker时获取ENVvariables检查有关如何从Docker检查中获取特定值的更多详细信息
- 在docker中创build一个纯数据镜像
- 我运行启动tomcat8服务器的docker图像,但它不启动
- docker中无法连接到端口9300上的elasticsearch
- 如何从另一个容器通过172.17.42.1:53:53/udp(docker0)的暴露端口访问容器(SkyDns)? Docker 1.7.1,Centos 7
- 如何将一个实例从一个子网运行到另一个运行了Docker容器的实例?
- Traefik使用非dockerized服务和dockerized应用程序
- 我如何访问在Windows操作系统的Docker工具箱Linux容器中创build的项目目录?
- Dockerfile COPY通配符只匹配文件,而不是文件夹
- 在Docker容器中创build用户