I tried installing this using the basic setup, but I seem to be getting this error:

In AbstractConnection.php line 132:
   `SELECT` failed: NOAUTH Authentication required. [tcp://127.0.0.1:6379]

When I run systemctl status redis it's saying that it is active (running).

I tried to troubleshoot by replacing "null" in the password section of extend.php with my redis password, but I'm getting this error instead:

PHP Parse error: syntax error, unexpected identifier "password" expecting "]" in /var/www/website/forum/extend.php on line 16

Now, I can't even access my forum as all I see is white screen. Lol. Good thing I took a snapshot of my droplet before attempting to install redis.

Did I miss something in the installation? Your help would be immensely appreciated. Thanks!

    Lurker the error is caused by a missing comma at the end of the previous line above password. Copy the contents of extend.php (mask the actual passwords) so that I can correct them (or send it on discord dm).

      5 days later

      luceos Copy the contents of extend.php (mask the actual passwords) so that I can correct them

      Please accept my apologies for the delayed response. I was trying to solve it to the best of my abilities, but I give up. 🤦‍♂️

      I added a comma after the host, password, port and database but now I'm getting a new error:
      PHP Parse error: syntax error, unexpected single-quoted string "port", expecting "]" in /var/www/website/forum/extend.php on line 17

      Here's the content of my extend.php:

      <?php
      
      /*
       * This file is part of Flarum.
       *
       * For detailed copyright and license information, please view the
       * LICENSE file that was distributed with this source code.
       */
      
      use Flarum\Extend;
      
      return [
          // Register extenders here to customize your forum!
          (new Blomstra\Redis\Extend\Redis([
              'host' => '127.0.0.1',
              'password' => password,
              'port' => 6379,
              'database' => 1,
          ]))
          ->useDatabaseWith('cache', 1)
          ->useDatabaseWith('queue', 2)
          ->useDatabaseWith('session', 3)
      ];

      Additional questions if I may:
      How does the Flarum-Redis differ from the other Blomstra extension: Realtime? If I understood the concepts correctly, the latter utilizes the master:slave system of Redis to queue tasks such as email sending; while the former takes it up to the next level by allowing all notifications to be pushed. Is that right?

      Thank you in advance for the help. 😀

        Lurker the new error seems to be caused by the password line, make sure to encapsulate the password in quotes and escape those quotes if they exist inside said password. If you have issues with this DM me on Discord with your exact extend.php for further help.

        Lurker Additional questions if I may:
        How does the Flarum-Redis differ from the other Blomstra extension: Realtime? If I understood the concepts correctly, the latter utilizes the master:slave system of Redis to queue tasks such as email sending; while the former takes it up to the next level by allowing all notifications to be pushed. Is that right?

        The realtime extension puts notifications it sends to users connected to the realtime websocket into a queue. Especially on larger communities using a queue becomes necessary as notification handling can delay processing of requests (like posting) up to a point where they seem to fail. This extension/package offers one form of queue, using redis, which is a very reliable set up.

          luceos make sure to encapsulate the password in quotes and escape those quotes if they exist inside said password

          Ahhh! This solved the PHP parse error. I think I missed the quotation marks as the password line of the guide only showed: 'password' => null,

          After entering the command php flarum queue:work all I see is a blank line signifying that the workers are waiting for a task. The document states that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal; but how do I make it manually stop without closing the terminal? Is it possible to keep it running in the background?

          Edited after reading all 233 posts

          Solution: There is no need to stop the process. The recommendation is to run it continuously with supervisor or systemd.

          For systemd, @matteocontrini, an excellent community member, suggests the following (added some lines for clarity)

          On distributions with systemd (e.g. Ubuntu), it's also possible to create a system service without installing anything.

          Create a file with an editor of your choice at /etc/systemd/system/flarum-queue.service with the following contents:

          [Unit]
          Description=flarum-queue
          After=network.target
          StartLimitIntervalSec=0

          [Service]
          Type=simple
          User=www-data
          WorkingDirectory=/var/www/path-to-flarum
          ExecStart=/usr/bin/php-version flarum queue:work
          Restart=always
          RestartSec=5

          [Install]
          WantedBy=multi-user.target

          To start the service:
          $sudo systemctl start flarum-queue.service

          To automatically start on reboots:
          $sudo systemctl enable flarum-queue.service

          I hope this helps other users.

          luceos This extension/package offers one form of queue, using redis, which is a very reliable set up.

          Can Flarum-Redis be run together with Blomstra-Realtime on the same Flarum community? From my understanding, both of them serve the same purpose, but I could be wrong. I'm still trying to wrap my head around the concept of a websocket so I truly appreciate your patience.

            Lurker Can Flarum-Redis be run together with Blomstra-Realtime on the same Flarum community?

            Yes they co-exist. In fact Realtime works better if a queue extension is enabled/working.

            Lurker From my understanding, both of them serve the same purpose, but I could be wrong.

            Yes you are wrong. Which I can completely understand. Let me try to narrow it down.

            Realtime makes Flarum more realtime by sending updates to the Flarum community html page you have open directly through a two-way continuous communication channel. For instance new posts being rendered inside a discussion, new discussions onto the index and the typing indicator without having to refresh the page; it does not add any backend functionality to move task processing (like sending notifications) to a queue.

            Blomstra Redis does not add any realtime updates to Flarum, it enables tasks to be processed in the background. Instead of having to wait for notifications (and other php/backend tasks) to be completed, a user on your community can simply post and see their post on the forum immediately. The more background tasks are scheduled when creating content, the longer the request to submit that content, unless you use a queue. Blomstra Redis enables a queue relying on Redis, Blomstra database queue enables one relying on the database.

            Additional resources:

            I was able to successfully create the flarum-queue.service file and had it started and enabled. This is the status of my flarum-queue.service:

            ● flarum-queue.service - flarum-queue
                 Loaded: loaded (/etc/systemd/system/flarum-queue.service; enabled; vendor>
                 Active: active (running) since Wed 2022-10-26 15:07:12 UTC; 10s ago
               Main PID: 8910 (php8.1)
                  Tasks: 1 (limit: 1116)
                 Memory: 28.0M
                    CPU: 218ms
                 CGroup: /system.slice/flarum-queue.service
                         └─8910 /usr/bin/php8.1 flarum queue:work

            However, when I tried to login to my site, I get this message:
            Oops! Something went wrong. Please reload the page and try again.

            I can't seem to log in to my own site now. I tried resetting my password, but it's saying that "An error occured. Please try again."

            Solution: Clear the Flarum cache by typing: php flarum cache:clear

            If you get a permission error like this:

            Could not clear contents of storage/cache. Please adjust file permissions and try again. This can frequently be fixed by clearing cache via the Tools dropdown on the Administration Dashboard page.

            Solution: Run the command as the web user by typing sudo -u www-data php flarum cache:clear

            Edited after several readings and droplet restores. Personal issues have now been resolved. Thanks!

            2 months later
            3 months later

            Hi, nice extension ! Is there a way to use config.php to enable / disable your extension ? Because I haven't Redis on my local environment.

              6 days later

              It makes verification mail cannot send correctly when I use Redis.
              That mail was sent correctly When I disabled Redis.
              Is there any solution to fix this?

                luceos
                I ran command:

                php flarum info

                  luceos
                  Thank you a lot, I saw this, And It works now.

                  Queue
                  Make sure to start your queue workers, see the laravel documentation for specifics.

                  To test the worker can start use php flarum queue:work.

                  Updating
                  composer update blomstra/flarum-redis
                  Make sure to restart your queue workers every time you upgrade flarum, add or remove extensions. So whenever you ran composer commands you have to restart the queue.

                  a month later

                  I got a Litespeed server web and cache by @rafaucau .
                  Can I use redis with litespeed cache?
                  I have a shared hosting.

                    4 months later

                    Are there any known problems with the Redis queue?

                    I have been experimenting with a copy of my forum on a DigitalOcean droplet. I installed a Redis server on the Ubuntu and installed this extension, then I put the proper configuration in the extend.php (using the one with three separate databases), I also made the Flarum queue a service.d following the excellent example of @matteocontrini (thank you!) and all seemed good for a while. I then disabled Pusher extension and whole hell broke loose! I couldn't access the forum anymore, I couldn't execute the "clear" command, the MySQL service hijacked the CPU and even after a restart it would still take the CPU and only a restart of the entire droplet fixed the MySQL problem, however the forum was still inaccessible. I had to remove this extension through the composer remove command in order to fix the problem.

                    Any advices? I was very optimistic about moving my forum from Siteground to a DigitalOcena droplet in order to benefit from a queue and then from the Blomstra Realtime, however the entire experience smashed my enthusiasm into zero and I'm wondering whether I can rely on these advanced extensions. Maybe it's me who is not experienced enough, which is why I'm asking if other members are happy with the Redis queue support and other realtime features?

                      20 days later

                      luceos Set up

                      In your extend.php:

                          new Blomstra\Redis\Extend\Redis([
                              'host' => '127.0.0.1',
                              'password' => null,
                              'port' => 6379,
                              'database' => 1,
                          ])

                      This enables sessions, cache and queue to run on redis.

                      When I run this I stop receiving notifications on site about the signups and posts ... Can anyone please tell me the right configuration for Redis sessions, cache & queues

                        xasharma make sure to daemonize the queue worker, otherwise the queue won't do anything at all.

                        CyberGene I missed this. There are no issues that I know of. In fact the redis queue is in use here on discuss and in many production communities for Blomstra. MySQL impact is usually influenced by one or a combination of extensions.. Make sure to restart the queue daemon when making changes to your enabled extensions (it should do that automatically though).