dg / ftp-deployment

A tool for automated deployment of web applications to an FTP server.
https://nette.org
Other
601 stars 89 forks source link

Cannot upload file with ftps on PHP7 #85

Open janedbal opened 8 years ago

janedbal commented 8 years ago

After update to PHP7 on Windows I tried to use ftps instead of ftp protocol since openssl is bundled in php, but deployment with ftps protocol doesn't work as expected.

If I run deployment via ftp, it works normally:

Loaded remote .htdeployment file
Scanning files in ...
Ignoring ....
Creating remote file .htdeployment.running

Uploading:
...

But if I run it with ftps i get strange error Error: Ok to send data. Also, the log falsely says that remote .htdeployment does not exist. File .htdeployment.running is created.

Remote .htdeployment file not found
Scanning files in ...
Ignoring ...
Creating remote file .htdeployment.running 
Error: Cannot upload file C:\Users\...\AppData\Local\Temp\deployment\dep189C.tmp, number of retries exceeded. Error: Ok to send data.

PHP 7.0.8, ftp-deployment 2.5, Wedos hosting

janedbal commented 8 years ago

@dg Any hints what should I try to help resolve this issue?

dg commented 8 years ago

It seems that ftp in PHP doesn't work with Wedos. I am unable to list files via

$f = ftp_ssl_connect('12345.w71.wedos.net');
ftp_login($f, 'user', 'password');
var_dump(ftp_nlist($f, '*'));  

ftp_connect works fine.

janedbal commented 8 years ago

Actually, this is more PHP problem than Wedos problem. After contacting their support I found that they require SSL session reuse, which is not implemented in PHP. Similar problem reported as PHP bug 70195


How to reproduce:

set_error_handler(function ($severity, $message) {
    echo $message;
});

$f = ftp_ssl_connect('12345.w91.wedos.net');
ftp_login($f, 'user', 'pass');
ftp_pasv($f, TRUE);
ftp_fput($f, 'file', fopen(__DIR__ . '/file', 'r'), FTP_BINARY);
ftp_fput(): SSL connection failed; session reuse required: see require_ssl_reuse option in vsftpd.conf man page`
janedbal commented 8 years ago

@dg So if you don't want to use alternative ftp client implementation, we can close this issue...


edit: Or maybe there might be some better error when this occurs.

dg commented 8 years ago

Do you know alternative client?

ad better error: it is good idea, can you send PR?

janedbal commented 8 years ago

The only one client which uses sockets I found is ngyuki/php-ftp-client, but it doesn't support ftps.

I'll try to find some time to send PR.

OndraM commented 8 years ago

FYI, SSL session reuse will be added to PHP 7.1 and 5.6.26.

dg commented 8 years ago

Great, so closing.

matak commented 7 years ago

$ php -v PHP 7.1.1 (cli) (built: Jan 18 2017 18:50:48) ( NTS MSVC14 (Visual C++ 2015) x86 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with blackfire v1.16.2~win-x32-non_zts71, https://blackfire.io, by Blackfireio Inc.

i have still same problem with this settings :(

dg commented 6 years ago

Still same problem with PHP 7.2.3

krystofklima commented 4 years ago

Hi all,

Have You someone solved this ??? I have same problém and in version 7.1.17

TheTEXcz commented 3 years ago

Hi all,

check if your temp folder exist. My was deleted and ftp_nlist returns bool(false).. I created it again and now it is ok.