routeros-api-php
routeros-api-php copied to clipboard
fix: improve PHP 8.4 stream timeout handling (issue #131)
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()withstream_get_meta_data()for clarity - Only throw timeout exception when timed_out=true AND no data received
- Add configurable
throw_timeout_exceptionoption
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