Redis cache works as expected
Error: Invalid field: Redis Server Port
Error: Redis connection failed
Cache is not working.
In the xml, the field for port is limited to 1
With Error Reporting enabled, i see this:
Notice: Undefined variable: connection in /home/lormar/public_html/libraries/src/Cache/Storage/RedisStorage.php on line 106
In System Debug i have:
Redis connection failed
Call stack
# Function Location
1 JError::raise() JROOT/libraries/legacy/error/error.php:299
2 JError::raiseWarning() JROOT/libraries/src/Cache/Storage/RedisStorage.php:113
3 Joomla\CMS\Cache\Storage\RedisStorage->getConnection() JROOT/libraries/src/Cache/Storage/RedisStorage.php:52
4 Joomla\CMS\Cache\Storage\RedisStorage->__construct() JROOT/libraries/src/Cache/CacheStorage.php:185
5 Joomla\CMS\Cache\CacheStorage::getInstance() JROOT/libraries/src/Cache/Cache.php:500
6 Joomla\CMS\Cache\Cache->_getStorage() JROOT/libraries/src/Cache/Cache.php:223
7 Joomla\CMS\Cache\Cache->get() JROOT/libraries/src/Cache/Controller/CallbackController.php:94
8 Joomla\CMS\Cache\Controller\CallbackController->get() JROOT/libraries/src/Component/ComponentHelper.php:453
9 Joomla\CMS\Component\ComponentHelper::load() JROOT/libraries/src/Component/ComponentHelper.php:519
10 Joomla\CMS\Component\ComponentHelper::getComponents() JROOT/libraries/src/Component/ComponentHelper.php:44
11 Joomla\CMS\Component\ComponentHelper::getComponent() JROOT/libraries/src/Component/ComponentHelper.php:103
12 Joomla\CMS\Component\ComponentHelper::getParams() JROOT/libraries/src/Access/Access.php:939
13 Joomla\CMS\Access\Access::getGroupsByUser() JROOT/libraries/src/Access/Access.php:1095
14 Joomla\CMS\Access\Access::getAuthorisedViewLevels() JROOT/libraries/src/User/User.php:458
15 Joomla\CMS\User\User->getAuthorisedViewLevels() JROOT/libraries/src/Plugin/PluginHelper.php:321
16 Joomla\CMS\Plugin\PluginHelper::load() JROOT/libraries/src/Plugin/PluginHelper.php:87
17 Joomla\CMS\Plugin\PluginHelper::getPlugin() JROOT/libraries/src/Plugin/PluginHelper.php:129
18 Joomla\CMS\Plugin\PluginHelper::isEnabled() JROOT/libraries/src/Application/CMSApplication.php:612
19 Joomla\CMS\Application\CMSApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:301
20 Joomla\CMS\Application\AdministratorApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:123
21 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:196
22 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/index.php:51
Redis connection failed
Call stack
# Function Location
1 JError::raise() JROOT/libraries/legacy/error/error.php:299
2 JError::raiseWarning() JROOT/libraries/src/Cache/Storage/RedisStorage.php:113
3 Joomla\CMS\Cache\Storage\RedisStorage->getConnection() JROOT/libraries/src/Cache/Storage/RedisStorage.php:52
4 Joomla\CMS\Cache\Storage\RedisStorage->__construct() JROOT/libraries/src/Cache/CacheStorage.php:185
5 Joomla\CMS\Cache\CacheStorage::getInstance() JROOT/libraries/src/Cache/Cache.php:500
6 Joomla\CMS\Cache\Cache->_getStorage() JROOT/libraries/src/Cache/Cache.php:223
7 Joomla\CMS\Cache\Cache->get() JROOT/libraries/src/Cache/Controller/CallbackController.php:94
8 Joomla\CMS\Cache\Controller\CallbackController->get() JROOT/libraries/src/Plugin/PluginHelper.php:359
9 Joomla\CMS\Plugin\PluginHelper::load() JROOT/libraries/src/Plugin/PluginHelper.php:87
10 Joomla\CMS\Plugin\PluginHelper::getPlugin() JROOT/libraries/src/Plugin/PluginHelper.php:129
11 Joomla\CMS\Plugin\PluginHelper::isEnabled() JROOT/libraries/src/Application/CMSApplication.php:612
12 Joomla\CMS\Application\CMSApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:301
13 Joomla\CMS\Application\AdministratorApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:123
14 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:196
15 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/index.php:51
Redis connection failed
Call stack
# Function Location
1 JError::raise() JROOT/libraries/legacy/error/error.php:299
2 JError::raiseWarning() JROOT/libraries/src/Cache/Storage/RedisStorage.php:113
3 Joomla\CMS\Cache\Storage\RedisStorage->getConnection() JROOT/libraries/src/Cache/Storage/RedisStorage.php:52
4 Joomla\CMS\Cache\Storage\RedisStorage->__construct() JROOT/libraries/src/Cache/CacheStorage.php:185
5 Joomla\CMS\Cache\CacheStorage::getInstance() JROOT/libraries/src/Cache/Cache.php:500
6 Joomla\CMS\Cache\Cache->_getStorage() JROOT/libraries/src/Cache/Cache.php:200
7 Joomla\CMS\Cache\Cache->contains()
8 call_user_func_array() JROOT/libraries/src/Cache/CacheController.php:71
9 Joomla\CMS\Cache\CacheController->__call() JROOT/libraries/src/Language/LanguageHelper.php:136
10 Joomla\CMS\Language\LanguageHelper::getLanguages() JROOT/plugins/system/languagefilter/languagefilter.php:96
11 PlgSystemLanguageFilter->__construct() JROOT/libraries/src/Plugin/PluginHelper.php:283
12 Joomla\CMS\Plugin\PluginHelper::import() JROOT/libraries/src/Plugin/PluginHelper.php:182
13 Joomla\CMS\Plugin\PluginHelper::importPlugin() JROOT/libraries/src/Application/CMSApplication.php:625
14 Joomla\CMS\Application\CMSApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:301
15 Joomla\CMS\Application\AdministratorApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:123
16 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:196
17 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/index.php:51
Redis connection failed
Call stack
# Function Location
1 JError::raise() JROOT/libraries/legacy/error/error.php:299
2 JError::raiseWarning() JROOT/libraries/src/Cache/Storage/RedisStorage.php:113
3 Joomla\CMS\Cache\Storage\RedisStorage->getConnection() JROOT/libraries/src/Cache/Storage/RedisStorage.php:52
4 Joomla\CMS\Cache\Storage\RedisStorage->__construct() JROOT/libraries/src/Cache/CacheStorage.php:185
5 Joomla\CMS\Cache\CacheStorage::getInstance() JROOT/libraries/src/Cache/Cache.php:500
6 Joomla\CMS\Cache\Cache->_getStorage() JROOT/libraries/src/Cache/Cache.php:223
7 Joomla\CMS\Cache\Cache->get() JROOT/libraries/src/Cache/Controller/CallbackController.php:94
8 Joomla\CMS\Cache\Controller\CallbackController->get() JROOT/libraries/src/Menu/SiteMenu.php:101
9 Joomla\CMS\Menu\SiteMenu->load() JROOT/libraries/src/Menu/AbstractMenu.php:76
10 Joomla\CMS\Menu\AbstractMenu->__construct() JROOT/libraries/src/Menu/SiteMenu.php:62
11 Joomla\CMS\Menu\SiteMenu->__construct() JROOT/libraries/src/Menu/AbstractMenu.php:131
12 Joomla\CMS\Menu\AbstractMenu::getInstance() JROOT/libraries/src/Application/CMSApplication.php:375
13 Joomla\CMS\Application\CMSApplication->getMenu() JROOT/libraries/src/Application/SiteApplication.php:275
14 Joomla\CMS\Application\SiteApplication->getMenu() JROOT/libraries/src/Router/SiteRouter.php:64
15 Joomla\CMS\Router\SiteRouter->__construct() JROOT/libraries/src/Router/Router.php:189
16 Joomla\CMS\Router\Router::getInstance() JROOT/libraries/src/Application/CMSApplication.php:491
17 Joomla\CMS\Application\CMSApplication::getRouter() JROOT/libraries/src/Application/SiteApplication.php:403
18 Joomla\CMS\Application\SiteApplication::getRouter() JROOT/plugins/system/languagefilter/languagefilter.php:145
19 PlgSystemLanguageFilter->onAfterInitialise() JROOT/libraries/joomla/event/event.php:70
20 JEvent->update() JROOT/libraries/joomla/event/dispatcher.php:160
21 JEventDispatcher->trigger() JROOT/libraries/src/Application/BaseApplication.php:108
22 Joomla\CMS\Application\BaseApplication->triggerEvent() JROOT/libraries/src/Application/CMSApplication.php:626
23 Joomla\CMS\Application\CMSApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:301
24 Joomla\CMS\Application\AdministratorApplication->initialiseApp() JROOT/libraries/src/Application/AdministratorApplication.php:123
25 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:196
26 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/index.php:51
Redis connection failed
Call stack
# Function Location
1 JError::raise() JROOT/libraries/legacy/error/error.php:299
2 JError::raiseWarning() JROOT/libraries/src/Cache/Storage/RedisStorage.php:113
3 Joomla\CMS\Cache\Storage\RedisStorage->getConnection() JROOT/libraries/src/Cache/Storage/RedisStorage.php:52
4 Joomla\CMS\Cache\Storage\RedisStorage->__construct() JROOT/libraries/src/Cache/CacheStorage.php:185
5 Joomla\CMS\Cache\CacheStorage::getInstance() JROOT/libraries/src/Cache/Cache.php:500
6 Joomla\CMS\Cache\Cache->_getStorage() JROOT/libraries/src/Cache/Cache.php:223
7 Joomla\CMS\Cache\Cache->get() JROOT/libraries/src/Cache/Controller/CallbackController.php:94
8 Joomla\CMS\Cache\Controller\CallbackController->get() JROOT/libraries/src/Helper/ModuleHelper.php:432
9 Joomla\CMS\Helper\ModuleHelper::getModuleList() JROOT/libraries/src/Helper/ModuleHelper.php:362
10 Joomla\CMS\Helper\ModuleHelper::load() JROOT/libraries/src/Helper/ModuleHelper.php:87
11 Joomla\CMS\Helper\ModuleHelper::getModules() JROOT/administrator/components/com_config/view/application/tmpl/default.php:46
12 include() JROOT/libraries/joomla/view/html.php:151
13 JViewHtml->render() JROOT/administrator/components/com_config/view/application/html.php:79
14 ConfigViewApplicationHtml->render() JROOT/components/com_config/controller/display.php:113
15 ConfigControllerDisplay->execute() JROOT/administrator/components/com_config/config.php:31
16 require_once() JROOT/libraries/src/Component/ComponentHelper.php:402
17 Joomla\CMS\Component\ComponentHelper::executeComponent() JROOT/libraries/src/Component/ComponentHelper.php:377
18 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/AdministratorApplication.php:101
19 Joomla\CMS\Application\AdministratorApplication->dispatch() JROOT/libraries/src/Application/AdministratorApplication.php:159
20 Joomla\CMS\Application\AdministratorApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:196
21 Joomla\CMS\Application\CMSApplication->execute() JROOT/administrator/index.php:51
PHP 7.2
J3.9.11
Redis 5.0.5 (redis.io)
phpredis 5.0.2 (PECL - CPanel)
host: /var/run/redis/redis_6379.sock
port: 0
Same settings in Magento 1.9.4.2 (that supports Redis natively) are working well (so it's not a server misconfiguration)
With:
host: localhost
port: 6379
... all is working well.
Labels |
Added:
?
|
Labels |
Added:
J3 Issue
|
Title |
|
Status | New | ⇒ | Discussion |
Hi @wilsonge ,
i use Redis from many years in Magento, lot of time before Joomla use it.
Port 0 in Redis is a "standard" to say to Redis "plugins" to use the unix socket.
https://www.google.com/search?q=redis+unix+socket&oq=redis+unix+socket
When you switch to "unix://var/run/redis/redis.sock" there is no more port logic.
Here, the first problem is that we need to be allowed to add 0 in the port field.
Then i see in
joomla-cms/libraries/src/Cache/Storage/RedisStorage.php
is missing the logic that use a UNIX socket like i see in joomla-cms/libraries/joomla/session/storage/redis.php
I don't understand why the "logic" of connection for Redis Cache have been written so differently than the code in Redis Session.
Am i wrong, or the connection logic to Redis should be uniform?
Significant work has been done in Joomla 4 to allow Redis to connect using a socket. This work was done by @csthomas in #18395
You can see here:
That if the first character of your REDIS HOST is a slash /
then Joomla will ignore the provided REDIS PORT and will set the port to 0
Also in the SessionFactory.php you can see that Joomla (WRONGLY!!!! - doesn't yet, but will after my PR) sets the port to 0 if the REDIS HOST starts with a /
Joomla then goes on to successfully make a redis connection using the sock.
Therefore you can safely IGNORE the port number in Joomla global config, and just provide any number - YOU DO NOT need to specify port 0.
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-05-14 20:42:40 |
Closed_By | ⇒ | richard67 |
Still getting the
Notice: Undefined variable: connection in /home/lormar/public_html/libraries/src/Cache/Storage/RedisStorage.php on line 106
with J3
Well I would not expect it to be fixed in J3 because the pull request was for J4. And as J3 is meanwhile in security only phase, it will not receive a fix for that anymore.
Any chance that this can be pushed to J5?
IANA classifies port 0 as a reserved port https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
This article suggests "Port 0 is a wildcard port that tells the system to find a suitable port number." (and various other google results :P)
Either way given it's reserved my gut feeling is that if Redis binds to this port it's a bug in redis rather than a bug in Joomla we can't connect to it