We are facing an issue with connecting a Laravel app on Azure App Service to an Azure Redis Cache instance on port 6380. We keep getting the error below.
ErrorException in StreamConnection.php line 246:
stream_socket_enable_crypto(): SSL: Handshake timed out
in StreamConnection.php line 246
at HandleExceptions->handleError('2', 'stream_socket_enable_crypto(): SSL: Handshake timed out', '/var/www/vendor/predis/predis/src/Connection/StreamConnection.php', '246', array('parameters' => object(Parameters), 'resource' => resource, 'metadata' => array('timed_out' => false, 'blocked' => true, 'eof' => false, 'stream_type' => 'tcp_socket/ssl', 'mode' => 'r+', 'unread_bytes' => '0', 'seekable' => false), 'options' => array('crypto_type' => '9')))
at stream_socket_enable_crypto(resource, true, '9') in StreamConnection.php line 246
The Redis block of code in the database config file looks like this:
'redis' => [
        'client' => 'predis',
        'cluster' => false,
        'default' => [
            'scheme' => 'tls',
            'host' => env('REDIS_HOST', 'localhost'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
            'read_write_timeout' => 0,
            // 'ssl' => [
            //     'verify_peer' => false,
            //     'verify_peer_name' => false,
            //     'allow_self_signed' => true
            // ]
            'context' => [
                // 'auth' => ['username', 'secret'],
                'stream' => [
                    'verify_peer' => true,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true
                    ],
            ],
        ],
        'options' => [
            'parameters' => ['password' => env('REDIS_PASSWORD', null)],
        ],
    ],
I am looking forward to pointers/tips on how to solve this issue. Thanks in advance.
This issue occurs due to scheme type 'tls'. Just remove scheme type 'tls' it will start working.
Note: This solution is for local setup only. Disabling SSL verification has security implications. Without verifying the authenticity of SSL/HTTPS connections, any malicious attacker can impersonate a trusted endpoint, and you'll be vulnerable to a Man-in-the-Middle Attack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With