2

Hope someone can help with this as a new install of PHP and Heroku Redis

This is the error I'm getting:- 2020-12-14T19:46:37.368544+00:00 app[web.1]: [14-Dec-2020 19:46:37 UTC] PHP Warning: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: 2020-12-14T19:46:37.368963+00:00 app[web.1]: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /app/vendor/predis/predis/src/Connection/StreamConnection.php on line 246 2020-12-14T19:46:37.369133+00:00 heroku[router]: at=info method=GET path="/v1/index.php" host=settingsapi.gtmforshopify.com request_id=b37a7e35-6813-4b57-98bc-96bcc9f0da20 fwd="82.69.152.94" dyno=web.1 connect=0ms service=53ms status=500 bytes=201 protocol=https 2020-12-14T19:46:37.369618+00:00 app[web.1]: [14-Dec-2020 19:46:37 UTC] PHP Fatal error: Uncaught Predis\Connection\ConnectionException: Error while switching to encrypted communication [rediss://ec2-23-21-210-25.compute-1.amazonaws.com:13579] in /app/vendor/predis/predis/src/Connection/AbstractConnection.php:155 2020-12-14T19:46:37.369716+00:00 app[web.1]: Stack trace: 2020-12-14T19:46:37.370064+00:00 app[web.1]: #0 /app/vendor/predis/predis/src/Connection/StreamConnection.php(247): Predis\Connection\AbstractConnection->onConnectionError() 2020-12-14T19:46:37.370396+00:00 app[web.1]: #1 /app/vendor/predis/predis/src/Connection/StreamConnection.php(107): Predis\Connection\StreamConnection->tlsStreamInitializer() 2020-12-14T19:46:37.370723+00:00 app[web.1]: #2 /app/vendor/predis/predis/src/Connection/AbstractConnection.php(81): Predis\Connection\StreamConnection->createResource() 2020-12-14T19:46:37.376422+00:00 app[web.1]: #3 /app/vendor/predis/predis/src/Connection/StreamConnection.php(258): Predis\Connection\AbstractConnection->connect() 2020-12-14T19:46:37.376880+00:00 app[web.1]: #4 /app/vendor/predis/predis/src/Connection/AbstractConnection.php(180): Predis\Connection\StreamConnection->connect() 2020-12-14T19:46:37.377341+00:00 app[web.1]: #5 /app/vendor/predis/predis/src/Connection/StreamConnection.php(288): Predis\Connection\AbstractConnection->getResource() 2020-12-14T19:46:37.377659+00:00 app[web.1]: #6 /app/vendor/predis/predis/src/Connect in /app/vendor/predis/predis/src/Connection/AbstractConnection.php on line 155

This is the code I'm using:-

Predis\Autoloader::register();

if (getenv('REDIS_URL')) {
    $url = parse_url(getenv('REDIS_URL'));

    putenv('REDIS_HOST='.$url['host']);
    putenv('REDIS_PORT='.$url['port']);
    putenv('REDIS_PASSWORD='.$url['pass']);
    putenv('REDIS_SCHEME='.$url['scheme']);
}

$options = [];
$options['ssl']['allow_self_signed'] = TRUE;
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;

$redis = new Predis\Client([
    'scheme'   => getenv('REDIS_SCHEME'),
    'host'   => getenv('REDIS_HOST'),
    'port'   => getenv('REDIS_PORT'),
    'password'   => getenv('REDIS_PASSWORD'),
    'database' => 0,
], $options);

2
  • Hi Rob, can you please add more info and wrap the error log in code blocks as well so it reads better and horizontal scrolls? Commented Dec 15, 2020 at 0:48
  • 1
    Hi, thanks for coming back to me, I tried everything I could think of to resolve the issue but ended up uninstalling the Heroku Redis addon and going with Redis To Go which worked right out of the box. Really disappointed with Heroku support and consequently I'm not looking at Heroku for a long term solution as I need excellent support for our production apps and it seems that Heroku don't offer that, it was impossible to contact them. Commented Dec 16, 2020 at 8:13

1 Answer 1

0

Add the predis package to your requirements in composer.json:

"require": {
  ...
  "predis/predis": "^1.1",
  ...
}

Connect to Redis using the REDIS_URL config var from the environment:

$redis = new Predis\Client(getenv('REDIS_URL') . "?ssl[verify_peer_name]=0&ssl[verify_peer]=0");

Reference: https://devcenter.heroku.com/articles/connecting-heroku-redis#connecting-with-predis

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.