Problem running Traccar in subdomain centos 7

Alaa Lahama year ago

I have a dedicated server with lots of sites on it and accounts and every account has domains and subdomains.
I was trying in the past few days to host Traccar on subdomain for an account, lets say the account name is user1, the account has a domain mydomain.com, I want to host Traccar on subdomain track.mydomain.com, and because Traccar needs root to be installed I installed it from root user using default installer, but I could not mange to direct my subdomain to Traccar installation at first, using the secure connection article and other tutorials did not helped me because my server installation of apache and the fact I have a lot of users and domains made it complex, and I am newbie in configuring apache .
Finally I learned how to create virtual host for my server and override my subdomain default virtual host using apache linked files.
so I created the following virtual host linked files:
1- std in path etc/apache2/conf.d/userdata/std/2_4/user1/track.mydomain.com/traccar.conf

ServerName track.mydomain.com
ServerAlias www.track.mydomain.com
ServerAdmin webmaster@track.mydomain.com
Redirect / https://track.mydomain.com/

2- ssl in path etc/apache2/conf.d/userdata/ssl/2_4/user1/track.mydomain.com/traccar.conf

ServerName track.mydomain.com
ServerAdmin webmaster@track.mydomain.com

DocumentRoot /opt/traccar

ProxyPass /api/socket ws://localhost:8082/api/socket
ProxyPassReverse /api/socket ws://localhost:8082/api/socket

ProxyPass / http://localhost:8082/
ProxyPassReverse / http://localhost:8082/

SSLEngine on
SSLCertificateFile /var/cpanel/ssl/apache_tls/track.mydomain.com/combined

And after that I am able to open Traccar web interface using my subdomain and login and add devices … etc.
But for example when I add a device it is not appearing immediate in the device list, it takes about 15 minutes to appear and everything is so slow, If I use Traccar client from mobile the device is not appearing online, after a while it appear online when I am actually offline, I can see everything I do in the database but not updated on the Traccar interface and I think I know why, in the browser log there is a we socket connection error appear every minute and I think we socket is not connected to my server, and that is why its not updating anything, I tried many solutions and ways to fix the we socket but nothing worked.
this is the we socket error:

WebSocket connection to 'wss://track.devbey.com/api/socket' failed: Error during WebSocket handshake: Unexpected response code: 405

Sorry for long post but i tried to be detailed as possible to help understand the problem

Anton Tananaeva year ago

What modules do you have enabled in Apache? Do you have WebSocket proxy enabled?

Alaa Lahama year ago

It was pre-enabled, I checked using this command, httpd -M | grep proxy and this is the output:

proxy_module (shared)
 proxy_fcgi_module (shared)
 proxy_http_module (shared)
 proxy_wstunnel_module (shared)
Anton Tananaeva year ago

Then I don't know why you have a WebSocket issue.

About the other stuff that you mention, like device doesn't appear when you add it, do you mean you added it from somewhere else? Maybe you can provide a screen recording?

Alaa Lahama year ago

No I added from web interface, everything I do in the interface not affected directly, does the web socket has something to do with that ?
I will provide recording to clarify the problem

Alaa Lahama year ago

And do you have suggestions to track the we socket issue ?

Anton Tananaeva year ago

You add it in the same app, same session and you don't see it in the list? Maybe you have some caching on the Apache that prevents the data from being updated?

Alaa Lahama year ago

Yes same app same session, It is not only appearing problem, when I am only or a device is online it's not appearing in the app as online, only after 10 or 15 minutes it appear, but i checked the log and the data from the traccar client is being received immediately.
About caching problem, there are about 40 websites on the server and no cache problem, but they are created using cPanel UI and WHM nothing special this is the first time i had to do something custom.
I did a video and now uploading it, i will send the link to video ASAP.

Anton Tananaeva year ago

Seems like you're just guessing that it's not a caching problem. I suggest you actually confirm that.

Alaa Lahama year ago

Video
this is the video.
How can I confirm it's not a caching problem ?
and what does the websocket error affect if it's not solved ?

Anton Tananaeva year ago

How can I confirm it's not a caching problem ?

Disable any caching that you have in Apache and try again?

and what does the websocket error affect if it's not solved ?

WebSocket is used to get live location updates and events. It's also used for device status, but you should still see full list of devices even if you have a WebSocket error. It's just the status might not get updated until refresh.

Alaa Lahama year ago

Lastly about websocket error no idea what might cause it ?

Anton Tananaeva year ago

If it works fine directly, but doesn't work with a proxy, there's some issue with the proxy configuration. What exactly - not sure, but it's not really something specific to Traccar.

Alaa Lahama year ago

Thank you for your help, I will update when everything is resolved

Alaa Lahama year ago

Sorry last thing if might remined you of provlem you know, sometimes i login and after login refresh page and i am logged out i re-login and refresh same thing happen again