nsq无法通过连接到nsqlookupd消耗消息 [英] nsq cannot consume message by connecting to nsqlookupd

查看:819
本文介绍了nsq无法通过连接到nsqlookupd消耗消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用docker-compose运行nsq,docker-compose.yml如下:

I tried to use docker-compose to run nsq, the docker-compose.yml as below:

version: '3'
services:
  nsqlookupd:
    image: nsqio/nsq
    command: /nsqlookupd
    ports:
      - "4160:4160"
      - "4161:4161"
  nsqd:
    image: nsqio/nsq
    command: /nsqd --lookupd-tcp-address=nsqlookupd:4160
    depends_on:
      - nsqlookupd
    ports:
      - "4150:4150"
      - "4151:4151"
  nsqadmin:
    image: nsqio/nsq
    command: /nsqadmin --lookupd-http-address=nsqlookupd:4161
    depends_on:
      - nsqlookupd
    ports:
      - "4171:4171"

我正在使用nsq客户端 go-nsq 来生成和使用消息,即消息可以通过直接连接到nsqd来使用,但是不能通过连接到nsqlookupd来使用:

I am using the nsq client go-nsq to produce and consume messages, the messages can be consumed by connecting to nsqd directly, but cannot be consumed by connecting to nsqlookupd:

consumer.ConnectToNSQD("127.0.0.1:4150")  # success (output the consumed messages)

consumer.ConnectToNSQLookupd("127.0.0.1:4161")   # failed

2018/01/31 16:39:12 ERR    1 [test/liu] (967fcc2c88ae:4150) error connecting to nsqd - dial tcp: i/o timeout

我可以连接到nsqlookup实例:

I can connect to nsqlookup instance:

➜  test_nsq curl http://127.0.0.1:4161/ping
OK%
➜  test_nsq curl http://127.0.0.1:4161/nodes
{"producers":[{"remote_address":"172.22.0.3:59988","hostname":"967fcc2c88ae","broadcast_address":"967fcc2c88ae","tcp_port":4150,"http_port":4151,"version":"1.0.0-compat","tombstones":[false],"topics":["test"]}]}%

源代码链接:

https://gist.github.com/liuzxc/1baf85cff7db8dee8c26b8707fc48799

Env:

OS: Mac EI Capitan 10.11.6
go version: 1.9.2
nsq: 1.0.0-compat(latest)

对此有任何想法吗?

推荐答案

我输出go-nsq日志,然后找到根本原因,应为nsqd命令添加-broadcast-address=127.0.0.1,否则,nsqd将其主机名注册到nsqlookupd ,客户端无法解决.

I output the go-nsq log, then find the root cause, should add -broadcast-address=127.0.0.1 for nsqd command, if not,nsqd will register its hostname to nsqlookupd, it cannot be resolved by client.

这篇关于nsq无法通过连接到nsqlookupd消耗消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆