Description
I am still debugging and investigating this, so hopefully it is not human error. Figured I would post in case anyone else is experiencing it or able to easily reproduce it.
Happens to me on versions > 2.6.0
, I did not test lower than that because my code is not compatible without some changes, so I decided to try to investigate the issue (or my misconfiguration).
I am using protocol version 5 clients (mqttjs, specifically).
Here is my server config:
server := mqtt.New(&mqtt.Options{
InlineClient: true,
Capabilities: &mqtt.Capabilities{
MaximumClients: math.MaxUint16,
MaximumSessionExpiryInterval: 0, // maximum number of seconds to keep disconnected sessions
MaximumMessageExpiryInterval: 60 * 60 * 24, // maximum message expiry if message expiry is 0 or over
ReceiveMaximum: 1024, // maximum number of concurrent qos messages per client
MaximumQos: 1, // maxmimum qos value available to clients
RetainAvailable: 1, // retain messages is available
MaximumPacketSize: 0, // no maximum packet size
TopicAliasMaximum: math.MaxUint16, // maximum topic alias value
WildcardSubAvailable: 1, // wildcard subscriptions are available
SubIDAvailable: 1, // subscription identifiers are available
SharedSubAvailable: 1, // shared subscriptions are available
MinimumProtocolVersion: 3, // minimum supported mqtt version (3.0.0)
MaximumClientWritesPending: 1024 * 8,
},
})
Here is my client settings:
keepalive: 60,
reconnectPeriod: 5000,
clean: false, //I've tried true as well, and with no assigned client id below
clientId: 'bob',
debug: true,
rejectUnauthorized: false,
Here is a screenshot of both my client simultaneously connected, and not being forcefully disconnected (also no client takeover occurred according to my logs.
Now if I publish a message, only one of them gets it (the latest to connect I think). Now this does seem like a client takeover.
So the 2 issues are:
- Client who was taken over, is not disconnected
- client event of this exchange is not set or happening (I log client takeovers, and not being detected)
Here is the code I am using to do that which used to work I think in older versions:
func (h *ConnectionStatusHook) OnDisconnect(client *mqtt.Client, err error, expire bool) {
if client.StopCause() == packets.ErrSessionTakenOver {
logErr := h.LogConnectionState(client.ID, CLIENT_TAKEOVER)
if logErr != nil {
sentry.CaptureException(err)
h.Log.Error("Error logging client takeover", "error", err)
}
return
}
On the metrics page I can see:
{
"version": "2.6.4",
"started": 1721337314,
"time": 1721337637,
"uptime": 323,
"bytes_received": 322,
"bytes_sent": 442,
"clients_connected": 2,
"clients_disconnected": 0,
"clients_maximum": 3,
"clients_total": 2,
"messages_received": 2,
"messages_sent": 3,
"messages_dropped": 0,
"retained": 0,
"inflight": 0,
"inflight_dropped": 0,
"subscriptions": 1,
"packets_received": 22,
"packets_sent": 22,
"memory_alloc": 3694592,
"threads": 15
}
Which is my 2 clients. Since its not being disconnected I guess is why the client stop isn't being detected. What's also interesting is the subscriptions
count is actually only 1
. Also when I ctrl+c the 2 terminals with the connections, I get the debug log of each disconnecting (and using the same client id).
So the root of the issue I think is the lack of the disconnect.
I'll try to see if I can find a fix or where the issue is!
Activity