fhmq / hmq

High performance mqtt broker
Apache License 2.0
1.33k stars 277 forks source link

did i cluster deploy right? #76

Open szx007 opened 4 years ago

szx007 commented 4 years ago

i wan't to deploy a cluster steps: start router ./router

start node1 /Users/kris/go/bin/hmq --clusterport 8099 --router :9888 --port 1883 mosquitto_sub -t testtest -p 1883

start node2 /Users/kris/go/bin/hmq --clusterport 8090 --router :9888 --port 1884 mosquitto_sub -t testtest -p 1883

pub message mosquitto_pub -p 1884 -t testtest -m "22"

but only node2 recv message did i cluster run right way?

chowyu08 commented 4 years ago

could you show the log of router?

szx007 commented 4 years ago

2020-03-19 18:28:22 INFO server.go :start listener on 0.0.0.0:9888

2020-03-19 18:33:23 INFO server.go :receive conn from client , clientID = c5eb95c4-3cd3-41cf-854c-c5c7a2cd4d92 keepAlive: 60 2020-03-19 18:33:23 DEBUG message.go :recv broker info: PUBLISH: dup: false qos: 0 retain: false rLength: 101 topicName: broker000100101info MessageID: 0 payload: {"brokerID":"c5eb95c4-3cd3-41cf-854c-c5c7a2cd4d92","brokerUrl":"127.0.0.1:8099"} brokerID = c5eb95c4-3cd3-41cf-854c-c5c7a2cd4d92 2020-03-19 18:33:30 INFO server.go :receive conn from client , clientID = 9e54e6aa-b16d-4ae9-989f-c290b572a331 keepAlive: 60 2020-03-19 18:33:30 DEBUG message.go :recv broker info: PUBLISH: dup: false qos: 0 retain: false rLength: 101 topicName: broker000100101info MessageID: 0 payload: {"brokerID":"9e54e6aa-b16d-4ae9-989f-c290b572a331","brokerUrl":"127.0.0.1:8090"} brokerID = 9e54e6aa-b16d-4ae9-989f-c290b572a331

szx007 commented 4 years ago

image

chowyu08 commented 4 years ago

node1 and node2 are same host?

broker ip is:127.0.0.1 https://github.com/fhmq/hmq/blob/55f1f1aa8001b422e4e648cf8240a2bdf0dbfd52/broker/client.go#L96

chowyu08 commented 4 years ago

你的集群建立好像是在你发消息之后,集群不好缓存消息目前

NasinLin commented 4 years ago

@chowyu08 我也是照上面做法做,node2 無法 subscribe node1 的消息。

jannson commented 4 years ago

很早就 stat 了作者的项目,一直没机会用。今天看到这个问题就尝试定位了下问题,不能用的原因:

https://github.com/fhmq/hmq/blob/master/broker/broker.go#L276

这个位置没较验通过,少了版本号与版本 ID

https://github.com/fhmq/hmq/blob/3cf90d5231d2a025fb68fd639551d4bfdb22fe11/broker/client.go#L341

其次是这里,没有处理 REMOTE 的情况,导致 broadcast 过来的消息没被处理。

想尝试修复下,发现还有其它问题,所以无法提交 PR

jannson commented 4 years ago

修复并测试成功,代码已经提交,请作者确认:

https://github.com/fhmq/hmq/pull/86