Skip to content

Commit

Permalink
Forcing multiple unsubscribes before new subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Souza committed Jul 28, 2017
1 parent 2da35e1 commit 66b5ad9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion bot/mqtt_bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ func (b *MQTTBot) StartBot() {
MessagePattern: pMap[string("messagePattern")].(string),
})
}
client.Unsubscribe(topic)

for i := 0; i < 10; i++ {
if tokenUnsubscribe := client.Unsubscribe(topic); tokenUnsubscribe.Wait() && tokenUnsubscribe.Error() != nil {
logger.Logger.Info(tokenUnsubscribe.Error())
}
}

if token := client.Subscribe(topic, uint8(qos), h); token.Wait() && token.Error() != nil {
logger.Logger.Fatal(token.Error())
}
Expand Down
3 changes: 2 additions & 1 deletion test_containers/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ services:
networks:
- mosqnet
mosquitto:
image: jllopis/mosquitto:v1.4.9
image: erlio/docker-vernemq
ports:
- "1883:1883"
environment:
- DOMAIN=example.local
- PORT=8080
- DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on
networks:
- mosqnet
depends_on:
Expand Down

0 comments on commit 66b5ad9

Please sign in to comment.