You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FTP with SSL: ftp_fput(): Connection timed out on successful writes #20240
But even the if exception was raised, the file is written successfully on the server.
But I expected this output instead:
no exception
PHP Version
PHP 8.4.13 (cli) (built: Oct 1 2025 20:33:51) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.4.13, Copyright (c) Zend Technologies
with Zend OPcache v8.4.13, Copyright (c), by Zend Technologies
and also on
PHP 8.2.29 (cli) (built: Jul 3 2025 13:07:49) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.29, Copyright (c) Zend Technologies
with Zend OPcache v8.2.29, Copyright (c), by Zend Technologies
Does this reproduce consistently? Yes
Is this a new issue after upgrading PHP versions (i.e. is this a regression)? No. same thing happens on 8.2 and 8.4
What FTP server software do you use? I will try to find out. ftp_systype returns Windows_NT
How large is the file you try to upload? small. few kb
How long is the timeout? I am using timeout defaults. The file is written and exception is thrown in 1-3 seconds
I tried reproducing this with no luck. This means that somewhere the poll system call returns 0 before any file descriptors were ready, i.e. in the event of a timeout.
The default FTP timeout is set to 90 seconds, but you state the file is uploaded in 1-3 seconds. So does the timeout warning appear immediately after the file is uploaded or only after a while (e.g. after 10s of seconds or 90 seconds)?
Also, despite this behaviour, in the docs is not mentioned that ftp_fput throws an exception, is this expected?
video.mov
I am testing this from a vagrant environment with ubuntu 22, but this shouldn't matter because I saw the same behaviour in production using other setup.
Is there anything for me to enable or change to see more logs for ftp_fput method to help you debug more?
The strace helped me understand the issue. Thanks.
The issue is related to the data_available and data_writeable functions in the FTP implementation, which always have a fixed polling time of 1000ms in a loop, but that doesn't play well together with the timeout handling which erroneously triggers if more than a second passed. Makes no sense.
Unfortunately, the GPT output is completely wrong.
I'll try to work on a fix.
Activity
ndossche commentedon Oct 20, 2025
Please provivde the following extra information:
ionutantohi commentedon Oct 20, 2025
Does this reproduce consistently? Yes
Is this a new issue after upgrading PHP versions (i.e. is this a regression)? No. same thing happens on 8.2 and 8.4
What FTP server software do you use? I will try to find out. ftp_systype returns Windows_NT
How large is the file you try to upload? small. few kb
How long is the timeout? I am using timeout defaults. The file is written and exception is thrown in 1-3 seconds
ionutantohi commentedon Oct 21, 2025
Microsoft Windows Server 2016, running IIS FTP (IIS version 10)
ndossche commentedon Oct 23, 2025
I tried reproducing this with no luck. This means that somewhere the poll system call returns 0 before any file descriptors were ready, i.e. in the event of a timeout.
The default FTP timeout is set to 90 seconds, but you state the file is uploaded in 1-3 seconds. So does the timeout warning appear immediately after the file is uploaded or only after a while (e.g. after 10s of seconds or 90 seconds)?
ionutantohi commentedon Oct 24, 2025
It appears immediately. check the video.
I searched if others experienced the same behaviour and I found only 1 occurrence on the laracast forum, but without any solution. https://laracasts.com/discuss/channels/laravel/getting-connection-timed-out-with-flysystem-ftp-even-when-the-file-appears-in-ftp
Also, despite this behaviour, in the docs is not mentioned that
ftp_fputthrows an exception, is this expected?video.mov
I am testing this from a vagrant environment with ubuntu 22, but this shouldn't matter because I saw the same behaviour in production using other setup.
Is there anything for me to enable or change to see more logs for
ftp_fputmethod to help you debug more?10 remaining items
ndossche commentedon Oct 25, 2025
The strace helped me understand the issue. Thanks.
The issue is related to the data_available and data_writeable functions in the FTP implementation, which always have a fixed polling time of 1000ms in a loop, but that doesn't play well together with the timeout handling which erroneously triggers if more than a second passed. Makes no sense.
Unfortunately, the GPT output is completely wrong.
I'll try to work on a fix.
Fix phpGH-20240: FTP with SSL: ftp_fput(): Connection timed out on su…
ionutantohi commentedon Oct 26, 2025
Thank you for looking at this!
Fix GH-20240: FTP with SSL: ftp_fput(): Connection timed out on succe…
Merge branch 'PHP-8.3' into PHP-8.4
Merge branch 'PHP-8.4' into PHP-8.5
Merge branch 'PHP-8.5'