HTTP 401 Unauthorized - WebApplicationException

Simone7 months ago

Hi, I'm using traccar 6.1 with horizontal scaling, but unfortunately when I log in I get the following error:

HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:132 < ... < OverrideFilter:49 < ...)

Sometimes I can log in without any errors. I'm using redis as a broadcast.
MySQL version 8 (Google cloud SQL)

Anton Tananaev7 months ago

Are you sure you have sticky sessions on your load balancer?

Simone7 months ago

I don't understand why it has to be sticky session if it saves the persistent session in the database.
I set web.persistSession=true.
Each instance should fetch it from the database.

Anton Tananaev7 months ago

I must be blind because I don't see this information in your original post.

Simone7 months ago

On the LoadBalancer the session is not stick because I thought that the user authentication sessions were saved in the database, this is an additional question.

Anton Tananaev7 months ago

I don't think we tested that scenario. In theory it probably should work, but I don't know if there are any gotchas. So the recommendation is to use sticky sessions.

Victor Butler6 months ago

That's interesting. I am not using a load balancer, just one server per instance (official release) and I get the same error intermittently - most of the time users can log in without any errors but every once in a while I get the same error:
HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:132 < ... < OverrideFilter:49 < ...)

Any pointers to what might be going wrong apart from traccar server restart?

William5 months ago

Hi, Anton. I'm using traccar-linux-64-6.2 for Linus 64.

I'm facing the same problem, but I'm not using load balance yet (I will). When accessing the web interface, it shows error 401.

HTTP 401 Unauthorized - WebApplicationException (SecurityRequestFilter:132 < ... < OverrideFilter:49 < ...)

I created a machine (EC2 Linux Ubuntu 22) on AWS to test Traccar and did a complete installation (App and Bank), everything worked correctly, with several devices (Web and Api). After a few days I shut down the server. When I restarted the Traccar server, the error appeared.
I created everything from scratch again, successfully tested all functionalities (Web and API). I restarted the Traccar Server machine and the error reappeared again, including via the API.
Can you tell me what would be causing this error and what could I do to fix it?
Thanks for your attention.

Error_401.JPG

Anton Tananaev5 months ago

Do you have a URL?

William5 months ago
Anton Tananaev5 months ago

Looks fine to me. Check the endpoint you get that error from.

William5 months ago

What can a restart on the EC2 machine where Traccar is located doing to prevent new authentication. Could it be something related to session loss, section persistence, cookies, etc.? I attached the printout of the browser console (Chrome v.125 - 64bits).
What could be causing the 401 error?
Error_401_Console.JPG

Anton Tananaev5 months ago

Yes, a restart can definitely cause a session loss.

William5 months ago

OK, but regarding the 401 error, what could be causing this error reported in this thread?
Why, when trying a new login, Traccar does not accept the credentials of a valid user, correctly registered in the Database tables?
Is there any specific configuration to be done in the configuration files?
Anton, could you please be more specific and detailed?

Anton Tananaev5 months ago

Not accepting credentials of a valid user is completely different thing from what we're discussing in this thread.