eusonlito / GPS-Tracker

GPS Tracker platform for Sinotrack, Coban, Teltonika, Concox, Jimilab, OsmAnd and Queclink devices built with Laravel 11 + PHP 8.2 and MySQL 8. Plataforma GPS Tracker para dispositivos Sinotrack Sinotrack, Coban, Teltonika, Concox, Jimilab, OsmAnd y Queclink creada con Laravel 11 + PHP 8.2 y MySQL 8.
https://tracker-demo.lito.com.es/
MIT License
199 stars 80 forks source link

Problem with server #34

Closed sajjadintel closed 10 months ago

sajjadintel commented 10 months ago

Hi, Thank you for your hard work. When I create a server, should I run it manually or not? It seems the server stops after a few hour. what is --reset ? It seems when server is running on port 6001, it tries to run it again and I seen port is occupied error. I sent **,imei:868166054696190,111 command and this is the response. It wasn't like this before. 1603010200010001fc03031700b78a6d6662ced60d428f8f9b4246cec7b333fe99a1a95a03da66c1ce084d20ce2447bece88dfab3f3597b592ac39288494fca50f6e38e811ca101b166ac31b0026baba130113021303c02bc02fcca9cca8c02cc030c009c013c00ac014009c009d002f0035000a0100018d3a3a0000000000180016000013747261636b696e67322e617261646f782e697200170000ff01000100000a000a00085a5a001d00170018000b0002010000230000000500050100000000000d00140012040308040401050308050501080606010201001200000033002b00295a5a000100001d002069ef802ec43f54220685733302b453c4a0ca6d1a94d59db4142c2314d4a8ff71002d00020101002b000b0a7a7a03040303030203016a6a000100001500da0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000


In Server.php line 111:

  socket_bind(): Unable to bind address [98]: Address already in use
01-01T23:24:02+00:00] production.ERROR: socket_bind(): Unable to bind address [98]: Address already in use {"url":"http://localhost","method":"GET","exception":"[object] (ErrorException(code: 0): socket_bind(): Unable to bind address [98]: Address already in use at /var/www/html/GPS-Tracker/app/Services/Server/Socket/Server.php:111)
eusonlito commented 10 months ago

Hi, I've just been improving the server management tonight.

Once the server is created, you should start the server from servers status panel, after that, the cronjob will check the server status to starting it automatically in case of crash, you don't have to launch it manually from the console.

The --reset option is used to stop the server in case it is running and start a new one.

Upgrade your installation with php8.2 ./composer deploy.

The code you have pasted looks like something in hexadecimal, it is strange, I would have to check it since in the documentation I think it does not show about that.

eusonlito commented 10 months ago

Coban devices use two communication protocols they call it (in,out) and the custom command you send does not respond because the default code is set to IN, you must send them the command by sms to the gps: protocol123456 18 out. Then try sending the command again and it should work. Anyway, you could reconfigure my server to test the responses.

sajjadintel commented 10 months ago

The server is stopped again:

[2024-01-02T12:23:19+00:00] production.ERROR: No arguments expected for "server:start:port" command, got "{--port=6001}". {"url":"http://localhost","method":"GET","exception":"[object] (Symfony\\Component\\Console\\Exception\\RuntimeException(code: 0): No arguments expected for \"server:start:port\" command, got \"{--port=6001}\". at /var/www/html/GPS-Tracker/vendor/symfony/console/Input/ArgvInput.php:196)
eusonlito commented 10 months ago

Do you have the cron configured? Are you executing the command from console?

sajjadintel commented 10 months ago

I have configured cron like this

* * * * * cd /var/www/html/GPS-Tracker && install -d storage/logs/artisan/$(date +"\%Y/\%m/\%d") && /usr/bin/php artisan schedule:run >> storage/logs/artisan/$(date +"\%Y/\%m/\%d")/schedule-run.log 2>&1
sajjadintel commented 10 months ago

Sorry the previous error was wrong. I deleted the logs and and rebooted the server. I get this error:

[2024-01-02T16:29:33+00:00] production.ERROR: Connection refused {"url":"http://localhost","method":"GET","exception":"[object] (RedisException(code: 0): Connection refused at /var/www/html/GPS-Tracker/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:161)

while redis is running

redis-cli ping
PONG
└─801 "/usr/bin/redis-server 127.0.0.1:6379"

I tried manually restart in panel but I got this error:

[2024-01-02T16:42:40+00:00] production.ERROR: App\Domains\Server\Exception\PortBusy: The server could not be started because the 6001 is not free in /var/www/html/GPS-Tracker/app/Domains/Server/Action/StartPort.php:114

seems panel wants to run with www-data user but cron runs as root

[2024-01-02T16:42:40+00:00] production.ERROR: App\Domains\Server\Exception\PortBusy: The server could not be started because the 6001 is not free in /var/www/html/GPS-Tracker/app/Domains/Server/Action/StartPort.php:114
eusonlito commented 10 months ago

Do you have configured redis in .env? Clear cache after config changes php artisan optimize.

sajjadintel commented 10 months ago

I belive yes

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
redis-cli -h 127.0.0.1 -p 6379 ping
PONG
eusonlito commented 10 months ago

Cron must run as webserver user (www-data).

sajjadintel commented 10 months ago

Thanks I will work on it

eusonlito commented 10 months ago

Can this issue be closed?

sajjadintel commented 10 months ago

Yeah I think the problem is resolved. Thanks.