matomo-org / matomo-org/plugin-QueuedTracking

matomo.php returns HTTP 200 when unable to connect to redis

Open
#97 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
87
Forks
41
Avg merge
2d 18h
Merged PRs (30d)
7

Description

If matomo is configured to use QueuedTracking with Redis as backend, and matomo.php is unable to connect to such Redis instance, HTTP 200 is returned.

I would expect matomo.php return !200. For monitoring the availability of the tracker API, it makes it harder to validate that the Tracker API is healthy.

The error msg that is returned:
```


Warning: Redis::connect(): connect() failed: Cannot assign requested address in /var/www/html/vendor/piwik/cache/src/Backend/Factory.php on line 60



Fatal error: Uncaught RedisException: Redis server went away in /var/www/html/vendor/piwik/cache/src/Backend/Factory.php:70
Stack trace:
#0 /var/www/html/vendor/piwik/cache/src/Backend/Factory.php(70): Redis->select(0)
#1 /var/www/html/vendor/piwik/cache/src/Backend/Factory.php(108): Piwik\Cache\Backend\Factory->buildRedisCache(Array)
#2 /var/www/html/core/Cache.php(75): Piwik\Cache\Backend\Factory->buildBackend('redis', Array)
#3 /var/www/html/config/global.php(67): Piwik\Cache::buildBackend('redis')
#4 [internal function]: DI\Definition\Source\DefinitionFile->{closure}(Object(DI\Container))
#5 /var/www/html/vendor/php-di/invoker/src/Invoker.php(82): call_user_func_array(Object(Closure), Array)
#6 /var/www/html/vendor/php-di/php-di/src/DI/Definition/Resolver/FactoryResolver.php(81): Invoker\Invoker->call(Object(Closure), Array)
#7 /var/www/html/vendor/php-di/php-di/src/DI/Definition/Resolver/ResolverDispatcher.php(58): DI\Definition\Resolver\FactoryResolver->resolve(Object(DI\Definition\FactoryDefinition), Array)
#8 /var in /var/www/html/vendor/piwik/cache/src/Backend/Factory.php on line 70
```

Headers returned:
```Request URL: X/matomo.php
Request Method: GET
Status Code: 200 ```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at matomo.php and trace the Redis failure through vendor/piwik/cache/src/Backend/Factory.php, core/Cache.php, and config/global.php. Reproduce a GET request with Redis unavailable and verify that the tracker returns a non-200 status instead of 200 when the connection fails.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, redis
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.