Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-81794

Redis cache with TLS results in Redis::connect() exception

XMLWordPrintable

    • MOODLE_404_STABLE
    • MOODLE_404_STABLE
    • MDL-81794-404
    • MDL-81794-main
    • Hide

      Setup

      Manual testing: Testing performance

      1. Log in as admin
      2. Navigate to Site Admin > Plugins > Caching > Redis
      3. Specify the test server with: 127.0.0.1:6380
      4. Tick the Use TLS encryption checkbox
      5. Save changes
      6. Navigate to Site Admin > Plugins > Caching > Test performance
      7. VERIFY the Redis result at the Store requests when used as an application cache table is tested without any errors.

      Manual testing: Cache store

      1. Log in as admin
      2. Navigate to Site Admin > Plugins > Caching > Configuration
      3. Add a Redis store by clicking Add instance link in the Redis row.
      4. Specif the input with the below value:
        • Store name: Store Redis
        • Server(s): 127.0.0.1:6380
        • Tick the Use TLS encryption checkbox
      5. Save changes
      6. VERIFY there is a new store name: Store Redis at the Configured store instances table and the Store mappings value is zero.
      7. Click Edit Mappings link at the bottom of the page.
      8. Select Store Redis at the Session dropdown.
      9. Save changes
      10. VERIFY the Store Redis at the Configured store instances table has Store mappings value is more than zero.

      Manual testing: Session

      1. Open the config.php and add the below codes: 

        $CFG->session_handler_class = '\core\session\redis';
        $CFG->session_redis_host = '127.0.0.1';
        $CFG->session_redis_port = 6380;
        $CFG->session_redis_encrypt = ['verify_peer' => false, 'verify_peer_name' => false];

      2. Open the browser and access the moodle.
      1. VERIFY login is working as usual and there is no any errors.

      Unit Testing

      1. Open config.php and add the below codes:

        define(
          'TEST_SESSION_REDIS_HOST',
          '127.0.0.1:6380'
        );
        define(
          'TEST_SESSION_REDIS_ENCRYPT',
          true
        );

      2. Make sure all the tests in lib/tests/session_redis_test.php are passed.

        mdk phpunit -r -u lib/tests/session_redis_test.php

      Show
      Setup Clone/Download https://github.com/meirzamoodle/docker-redis-ssl/tree/main and follow the instructions on the README. Manual testing: Testing performance Log in as admin Navigate to Site Admin > Plugins > Caching > Redis Specify the test server with: 127.0.0.1:6380 Tick the Use TLS encryption checkbox Save changes Navigate to Site Admin > Plugins > Caching > Test performance VERIFY the Redis result at the Store requests when used as an application cache table is tested without any errors. Manual testing: Cache store Log in as admin Navigate to Site Admin > Plugins > Caching > Configuration Add a Redis store by clicking Add instance link in the Redis row. Specif the input with the below value: Store name: Store Redis Server(s): 127.0.0.1:6380 Tick the Use TLS encryption checkbox Save changes VERIFY there is a new store name: Store Redis at the Configured store instances table and the Store mappings value is zero. Click Edit Mappings link at the bottom of the page. Select Store Redis at the Session dropdown. Save changes VERIFY the Store Redis at the Configured store instances table has Store mappings value is more than zero. Manual testing: Session Open the config.php and add the below codes:  $CFG->session_handler_class = '\core\session\redis' ; $CFG->session_redis_host = '127.0.0.1' ; $CFG->session_redis_port = 6380 ; $CFG->session_redis_encrypt = [ 'verify_peer' => false , 'verify_peer_name' => false ]; Open the browser and access the moodle. VERIFY login is working as usual and there is no any errors. Unit Testing Open config.php and add the below codes: define(   'TEST_SESSION_REDIS_HOST' ,   '127.0.0.1:6380' ); define(   'TEST_SESSION_REDIS_ENCRYPT' ,   true ); Make sure all the tests in lib/tests/session_redis_test.php are passed. mdk phpunit -r -u lib/tests/session_redis_test.php
    • 2
    • Team Hedgehog 2024 Sprint 2.1, Team Hedgehog 2024 Sprint 2.2

      In Moodle 4.4, the Redis cache code was updated to support cluster mode configuration (MDL-63128).

      However, this introduced an issue where Redis cache configurations with TLS enabled, with an error Exception - Redis::connect(): Argument #2 ($port) must be of type int, string given

      Specifically, the issue is https://github.com/moodle/moodle/blob/v4.4.0/cache/stores/redis/lib.php#L263 - if encryption is enabled, then the string $trimmedservers[0] will be "tls://redis.example:6380", which gets exploded to $server="tls" and $port="//redis.example".

        1. result_1.png
          result_1.png
          238 kB
        2. result_2.png
          result_2.png
          248 kB
        3. result_3.png
          result_3.png
          250 kB
        4. result_4.png
          result_4.png
          104 kB
        5. result_5.png
          result_5.png
          196 kB

            meirza.arson@moodle.com Meirza
            jlaundry- Jed Laundry
            David Woloszyn David Woloszyn
            Andrew Lyons Andrew Lyons
            Huong Nguyen Huong Nguyen
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 3 hours, 16 minutes
                2d 3h 16m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.