PHP - ftp_close(): SSL_read on shutdown

I have problem with ftp_close() function. I established connection over ftp_ssl_connect: $connection = ftp_ssl_connect('host', 21, 100); Download some files and everything is ok. But when I tried to close the connection by ftp_close($connection); I got error ftp_close(): SSL_read on shutdown. I tried to google it, but without no success.

The funny thing is, that everything is running in docker and error appears only in production environment which is totaly same and running on AWS.

Resolved! It's a problem of PHP 7.2. I posted a bug report here: https://bugs.php.net/bug.php?id=77151

Thanks for your effort :)

PHP :: Bug #77151 :: ftp_close(): SSL_read on shutdown, Fix #77151 ftp_close(): SSL_read on shutdown #3666. remicollet:issue-77151 ERR_clear_error();. nread = SSL_read(ssl_handle, buf, sizeof(buf));. Description: ----- ftp_close() function returns warning while trying to close SSL connection. Exact stdout: ftp_close(): SSL_read on shutdown I run following testscript with latest docker php7-cli image.

Try connecting before logging like thus:

$ftp_conn = ftp_ssl_connect(YOUR_SERVER);

$ftp_login = ftp_login($ftp_conn, YOUR_USERNAME, YOUR_PASSWORD);

ftp_close($ftp_conn);

Fix #77151 ftp_close(): SSL_read on shutdown · Issue #3666 · php , But when I tried to close the connection by ftp_close($connection); I got error ftp_close(): SSL_read on shutdown . I tried to google it, but without  Fix #77151 ftp_close(): SSL_read on shutdown #3666 remicollet wants to merge 1 commit into php : master from remicollet : issue-77151 Conversation 15 Commits 1 Checks 0 Files changed

Have you check your connection variable after connecting, try debugging by print_r and var_dump, it will help you to understand the issue, may be some other function or variable modifying $connection

bool ftp_close ( resource $ftp_stream ) Returns TRUE on success or FALSE on failure.

ftp_close() closes the given link identifier and releases the resource.

<?php

// set up basic connection
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// print the current directory
echo ftp_pwd($conn_id); // /

// close this connection
ftp_close($conn_id);
?>

PHP - ftp_close(): SSL_read on shutdown, I got error ftp_close(): SSL_read on shutdown . I tried to google it, but without no success. The funny thing is, that everything is running in docker  This raise warning during ftp_close, such as: PHP Warning: ftp_close(): SSL_read on shutdown: Success (0) in import.php on line 62 This comment has been minimized.

PHP - ftp_close(): SSL_read on shutdown, Warning: ftp_close(): SSL_read on shutdown: Connection reset by peer (104) in /​volume4/web/cserp/wp-admin/includes/class-wp-filesystem-ftpext.php on line  ftp_close() closes the given link identifier and releases the resource. Note: . After calling this function, you can no longer use the FTP connection and must create a new one with ftp_connect().

Can't upgrade to 5.2, Fixed bug #77231 (Segfault when using convert.quoted-printable-encode filter). ftp: Fixed bug #77151 (ftp_close(): SSL_read on shutdown). 1 PHP - ftp_close(): SSL_read on shutdown Nov 13 '18 0 Obtain temporary access to folder inside Google Storage bucket Jul 25 '19 0 Microsoft Azure and SAS for PHP May 24 '19

PHP 5.6.39, 7.0.33, 7.1.25, 7.2.13 released, The ftp_close() function is used to close an FTP connection. This works because the closing PHP tag acts as the terminator for the single  0 PHP - ftp_close(): SSL_read on shutdown Nov 13 '18 0 PHP Array how to make it so that all arrays will have the same length Nov 13 '18 0 Replacing integers with variables in SQL commands in python Nov 13 '18

Comments
  • This bug still exists in PHP7.4.1
  • It does return this in production server /PHP Warning: ftp_close(): SSL_read on shutdown: Success (0)
  • Try to close ssl connection first and then close ftp connection. SSL_shutdown() shuts down an active TLS/SSL connection. It sends the "close notify" shutdown alert to the peer. openssl.org/docs/man1.1.1/man3/SSL_shutdown.html