Fix closing
This commit is contained in:
parent
bae535a014
commit
44d57143d0
|
|
@ -166,11 +166,7 @@ func (s *MQTTBrokersService) PublishTopic(brokerId int64, topic string, message
|
||||||
func (s *MQTTBrokersService) StopListeners() {
|
func (s *MQTTBrokersService) StopListeners() {
|
||||||
if s.MqttWaitGroup != nil {
|
if s.MqttWaitGroup != nil {
|
||||||
for _, client := range s.MqttClients {
|
for _, client := range s.MqttClients {
|
||||||
if client.Client == nil {
|
client.Close()
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
client.Client.Disconnect(250)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.MqttWaitGroup.Wait()
|
s.MqttWaitGroup.Wait()
|
||||||
|
|
@ -181,11 +177,7 @@ func (s *MQTTBrokersService) EnsureListeners() {
|
||||||
if s.MqttWaitGroup != nil {
|
if s.MqttWaitGroup != nil {
|
||||||
// Disconnect all existing clients
|
// Disconnect all existing clients
|
||||||
for _, client := range s.MqttClients {
|
for _, client := range s.MqttClients {
|
||||||
if client.Client == nil {
|
client.Close()
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
client.Client.Disconnect(250)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all channels to clear
|
// Wait for all channels to clear
|
||||||
|
|
@ -264,7 +256,7 @@ func (s *MQTTBrokersService) EnsureListeners() {
|
||||||
for {
|
for {
|
||||||
data, ok := <-client.Channel
|
data, ok := <-client.Channel
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Println("WARN: MQTT channel closed")
|
log.Println("WARN: MQTT channel closed unexpectedly")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue