mirror of
https://github.com/fhmq/hmq.git
synced 2026-05-04 07:08:32 +00:00
fix: close the connection after send connection refused connack packet. (#121)
This commit is contained in:
@@ -279,21 +279,25 @@ func (b *Broker) handleConnection(typ int, conn net.Conn) {
|
||||
connack.ReturnCode = msg.Validate()
|
||||
|
||||
if connack.ReturnCode != packets.Accepted {
|
||||
err = connack.Write(conn)
|
||||
if err != nil {
|
||||
log.Error("send connack error, ", zap.Error(err), zap.String("clientID", msg.ClientIdentifier))
|
||||
return
|
||||
}
|
||||
func() {
|
||||
defer conn.Close()
|
||||
err = connack.Write(conn)
|
||||
if err != nil {
|
||||
log.Error("send connack error, ", zap.Error(err), zap.String("clientID", msg.ClientIdentifier))
|
||||
}
|
||||
}()
|
||||
return
|
||||
}
|
||||
|
||||
if typ == CLIENT && !b.CheckConnectAuth(string(msg.ClientIdentifier), string(msg.Username), string(msg.Password)) {
|
||||
connack.ReturnCode = packets.ErrRefusedNotAuthorised
|
||||
err = connack.Write(conn)
|
||||
if err != nil {
|
||||
log.Error("send connack error, ", zap.Error(err), zap.String("clientID", msg.ClientIdentifier))
|
||||
return
|
||||
}
|
||||
func() {
|
||||
defer conn.Close()
|
||||
err = connack.Write(conn)
|
||||
if err != nil {
|
||||
log.Error("send connack error, ", zap.Error(err), zap.String("clientID", msg.ClientIdentifier))
|
||||
}
|
||||
}()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user