Skip to content

Commit 27cabb6

Browse files
authored
Merge pull request #6 from cgauge/aws-network-issues
Retry connection with AWS Elasticache before crashing the request
2 parents 8f50ec2 + 9719fe5 commit 27cabb6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/SessionRetriever.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ public function retrieve(): array
4747
ini_set('session.cookie_secure', (string) $this->secure);
4848
ini_set('session.cookie_httponly', '1');
4949

50-
session_start();
50+
// When AWS Elasticache DNS resolution fails, PHP throws an error
51+
// session_start(): php_network_getaddresses: getaddrinfo failed: Name or service not known
52+
// This error is happening on 0.02% of our requests and AWS treat it as transient network
53+
// issues. Retrying before giving up might mitigate the problem.
54+
retry(3, function () {
55+
session_start();
56+
});
5157

5258
$this->session = $_SESSION;
5359

0 commit comments

Comments
 (0)