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"
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
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"]}]}%
the source code link:
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)
Any idea for this?