routeros-api-php icon indicating copy to clipboard operation
routeros-api-php copied to clipboard

fix: improve PHP 8.4 stream timeout handling (issue #131)

Open sonarta opened this issue 3 weeks ago • 0 comments

Problem

Users report StreamException: Stream timed out error when using PHP 8.4, particularly when retrieving large amounts of data.

Solution

  • Replace socket_get_status() with stream_get_meta_data() for clarity
  • Only throw timeout exception when timed_out=true AND no data received
  • Add configurable throw_timeout_exception option

Testing

Tested on PHP 8.4.15 with RouterOS 7.12.1:

  • ✅ 12 stress tests passed
  • ✅ 72,788 total records retrieved
  • ✅ Zero stream timeout errors

Usage

If issues persist, disable timeout exception:

$client = new Client([
    'throw_timeout_exception' => false,
]);

Fixes #131

sonarta avatar Dec 10 '25 09:12 sonarta