Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Post by zicht »

Hi

Can anyone point me to the cause of an sql error that i see once or twice a day :
Error: SQL Query("UPDATE UserSessions set AuthToken = 'debed44de6a452bd8db46921d6c959f0', ExpirationDate = '2019-04-06 21:01:12', RemoteHost = '192.168.xxx.xxx', LastUpdate = datetime('now', 'localtime') WHERE SessionID = 'abe8a64dbf643742096b24bc51f1bd8'") : UNIQUE constraint failed: UserSessions.AuthToken
so i can try to solve it :)

Many thanks
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
schumi2004
Posts: 24
Joined: Tuesday 17 October 2017 19:38
Target OS: NAS (Synology & others)
Domoticz version: 4.10603
Contact:

Re: Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Post by schumi2004 »

Same here.
Noticed it by accident and have no idea were it comes from or why it is happening.
In my situation it looks like there is a incomming connection from my router but have no idea why.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Post by waaren »

zicht wrote: Sunday 07 April 2019 20:18 Can anyone point me to the cause of an sql error that i see once or twice a day :
Error: SQL Query("UPDATE UserSessions set AuthToken = 'debed44de6a452bd8db46921d6c959f0', ExpirationDate = '2019-04-06 21:01:12', RemoteHost = '192.168.xxx.xxx', LastUpdate = datetime('now', 'localtime') WHERE SessionID = 'abe8a64dbf643742096b24bc51f1bd8'") : UNIQUE constraint failed: UserSessions.AuthToken
Opened issue 3156 for this on github. Seems to be caused by a change back in february causing the AuthToken to be set to the encoded SessionId
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Post by waaren »

schumi2004 wrote: Monday 22 April 2019 0:59
zicht wrote: Sunday 07 April 2019 20:18Can anyone point me to the cause of an sql error that i see once or twice a day :
Error: SQL Query("UPDATE UserSessions set AuthToken = 'debed44de6a452bd8db46921d6c959f0', ExpirationDate = '2019-04-06 21:01:12', RemoteHost = '192.168.xxx.xxx', LastUpdate = datetime('now', 'localtime') WHERE SessionID = 'abe8a64dbf643742096b24bc51f1bd8'") : UNIQUE constraint failed: UserSessions.AuthToken
This was caused by the function that creates the SessionID token and the AuthToken when a new session (or API call) enters domoticz. If called in the same second it generated the same values. It's solved in V4.10620 where the same random seed is not generated again when called in the same second.
If not please revert.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
zicht
Posts: 272
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Post by zicht »

[/quote]
This was caused by the function that creates the SessionID token and the AuthToken when a new session (or API call) enters domoticz.
[/quote]

Found it was in my installation indeed an api call ... Thanks.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: Error: SQL Query("UPDATE UserSessions set AuthToken : UNIQUE constraint failed: UserSessions.AuthToken

Post by MikeF »

I am getting frequent error messages in Domoticz, such as the following:

2023-06-05 08:35:12.064 Error: SQL Query("UPDATE UserSessions set AuthToken = '1518e7f3279398e62ccff3f3e1babed0', ExpirationDate = '2023-06-05 08:45:12', RemoteHost = '192.168.0.55', LastUpdate = datetime('now', 'localtime') WHERE SessionID = 'f286a97cbe825ce9a2ce73e0f26056b9'") : UNIQUE constraint failed: UserSessions.AuthToken

I am running Domoticz 2022.2 on an RPi 4B under Buster. The RemoteHost (consistently) referred to in these messages is an Apple iMac, used to access the Domoticz webserver.

I understood that this had previously been fixed, in v4.10620:
waaren wrote: Wednesday 24 April 2019 14:12
schumi2004 wrote: Monday 22 April 2019 0:59
zicht wrote: Sunday 07 April 2019 20:18Can anyone point me to the cause of an sql error that i see once or twice a day :
This was caused by the function that creates the SessionID token and the AuthToken when a new session (or API call) enters domoticz. If called in the same second it generated the same values. It's solved in V4.10620 where the same random seed is not generated again when called in the same second.
If not please revert.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest