Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "expensify/bedrock-php",
"description": "Bedrock PHP Library",
"type": "library",
"version": "2.1.3",
"version": "2.1.4",
"authors": [
{
"name": "Expensify",
Expand Down
24 changes: 1 addition & 23 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,29 +552,7 @@ private function sendRawRequest(string $host, int $port, string $rawRequest)
@socket_connect($this->socket, $host, $port);
$socketErrorCode = socket_last_error($this->socket);
if ($socketErrorCode === 115) {
$this->logger->info('Bedrock\Client - socket_connect returned EINPROGRESS, waiting for connection to complete');

// Use select to wait for the socket to become writable (indicates connection completion)
$write = [$this->socket];
$read = null;
$except = null;

$selectResult = socket_select($read, $write, $except, $this->connectionTimeout, $this->connectionTimeoutMicroseconds);
if ($selectResult === false) {
$socketError = socket_strerror(socket_last_error());
throw new ConnectionFailure("Failed to select on socket for host $host:$port. Error: $socketError");
} elseif ($selectResult === 0) {
throw new ConnectionFailure("Connection timeout while waiting for EINPROGRESS completion for host $host:$port");
}

// Check if connection completed successfully
$connectionError = socket_get_option($this->socket, SOL_SOCKET, SO_ERROR);
if ($connectionError !== 0) {
$socketError = socket_strerror($connectionError);
throw new ConnectionFailure("Connection failed after EINPROGRESS for host $host:$port. Error: $connectionError $socketError");
}

$this->logger->info('Bedrock\Client - EINPROGRESS connection completed successfully');
$this->logger->info('Bedrock\Client - socket_connect returned error 115, continuing.');
} elseif ($socketErrorCode) {
$socketError = socket_strerror($socketErrorCode);
throw new ConnectionFailure("Could not connect to Bedrock host $host:$port. Error: $socketErrorCode $socketError");
Expand Down
Loading