FTPPutFile() requires too minutes to upload
FTPPutFile() requires too minutes to upload
hi at all.
I have inserted a function into my programs that uploads a text file to an FTP server which I then access to consult some usage information.
lUpLoad := FTPPutFile( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 )
The function runs when the program closes, but it takes too long (many minutes) to upload, so the program stays active in background.
Once the first upload is complete, subsequent uploads take a few seconds.
Is it possible to prevent the first upload from taking that long?
thanks
I have inserted a function into my programs that uploads a text file to an FTP server which I then access to consult some usage information.
lUpLoad := FTPPutFile( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 )
The function runs when the program closes, but it takes too long (many minutes) to upload, so the program stays active in background.
Once the first upload is complete, subsequent uploads take a few seconds.
Is it possible to prevent the first upload from taking that long?
thanks
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: FTPPutFile() requires too minutes to upload
Can you provide a reduced and self-contained sample to reproduce the problem, please? We also need a test FTP account to make a test.
Re: FTPPutFile() requires too minutes to upload
Thank you so much, Enrico, for your help.
I created a minimal function, but I can't provide you with a test FTP account. I'm staying with a friend who has an account at aruba.it.
Could my problem be due to security restrictions on the Aruba server? Or to the PC firewalls?
Every time I change the program's execution folder on my PC, uploading the file via FTP takes this interminable time.
The name of the file being uploaded is encrypted with the CharOdd() and CharEven() functions. Could this cause security issues when accessing it?
If you have any suggestions or modifications to the function, you're welcome. In the meantime, I'd better try to test it by removing the encryption and making some other changes.
UpLoadFile("File.txt", "ecc.it/users/")
FUNCTION UpLoadFile(cFile, cWhere)
LOCAL oInternet, oFtp, lUpLoad := .f.
oInternet := tInternet():New()
IF oInternet:hSession != 0
oFtp := tFtp():New("ftp.ecc.it", oInternet, cUser, cPass, 134217728)
IF oFtp:hFTP != 0
lUpLoad := FTPPutFile( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 ) // PUNTO CRITICO CHE IMPIEGA MINUTI LA 1° VOLTA !
oFtp:End()
ENDIF
oInternet:End()
ENDIF
Return(lUpLoad)
I created a minimal function, but I can't provide you with a test FTP account. I'm staying with a friend who has an account at aruba.it.
Could my problem be due to security restrictions on the Aruba server? Or to the PC firewalls?
Every time I change the program's execution folder on my PC, uploading the file via FTP takes this interminable time.
The name of the file being uploaded is encrypted with the CharOdd() and CharEven() functions. Could this cause security issues when accessing it?
If you have any suggestions or modifications to the function, you're welcome. In the meantime, I'd better try to test it by removing the encryption and making some other changes.
UpLoadFile("File.txt", "ecc.it/users/")
FUNCTION UpLoadFile(cFile, cWhere)
LOCAL oInternet, oFtp, lUpLoad := .f.
oInternet := tInternet():New()
IF oInternet:hSession != 0
oFtp := tFtp():New("ftp.ecc.it", oInternet, cUser, cPass, 134217728)
IF oFtp:hFTP != 0
lUpLoad := FTPPutFile( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 ) // PUNTO CRITICO CHE IMPIEGA MINUTI LA 1° VOLTA !
oFtp:End()
ENDIF
oInternet:End()
ENDIF
Return(lUpLoad)
Re: FTPPutFile() requires too minutes to upload
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: FTPPutFile() requires too minutes to upload
I have an FTP account on Aruba too. I tried your sample with my account. The first time I run it, Windows Firewall asked me to allow the EXE, then it worked fine without any delay.
Re: FTPPutFile() requires too minutes to upload
Enrico,
Try answering "no" to the firewall permission. You may need to rename the folder.
a good portion of users answer "no"
Thanks Karinha for the suggested posts. I'll study them...
Try answering "no" to the firewall permission. You may need to rename the folder.
a good portion of users answer "no"
Thanks Karinha for the suggested posts. I'll study them...
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: FTPPutFile() requires too minutes to upload
If you answer no to the firewall then the program FTP communication will not work at all. That is normal and expected behavior.
Re: FTPPutFile() requires too minutes to upload
Of course, if I answer "no" or "cancel," it won't load anything, but that's when it crashes. The function I posted should intercept the firewall's "no" and not launch the FTPPutFile() function, and it keeps doing that every time.
How can I verify that the firewall has not granted me permission?
How can I verify that the firewall has not granted me permission?
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: FTPPutFile() requires too minutes to upload
Maybe none of those IFs control the firewall.
I need to make sure that if someone doesn't give permission, the function FTPPutFile() isn't launched.
I need to make sure that if someone doesn't give permission, the function FTPPutFile() isn't launched.
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: FTPPutFile() requires too minutes to upload
Thanks Enrico.
I'll do it.
I just verified that it's the function FTPPutFile() itself that triggers the firewall request, so it's not possible to exclude the function call with an IF statement.
I'll do it.
I just verified that it's the function FTPPutFile() itself that triggers the firewall request, so it's not possible to exclude the function call with an IF statement.
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: FTPPutFile() requires too minutes to upload
I just tried this test below: it show a little dialog with .F. when the program is blocked by the firewall.
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
? UPLOADFILE( "TEST.PRG", "emagsoftware.it/test/" )
RETURN NIL
#define FTP_TRANSFER_TYPE_BINARY 2
STATIC FUNCTION UPLOADFILE( cFile, cWhere )
LOCAL oInternet, oFtp, lUpLoad := .F.
oInternet = TInternet():New()
IF oInternet:hSession != 0
oFtp = TFtp():New( "ftp.emagsoftware.it", oInternet, "userid", "password" )
IF oFtp:hFTP != 0
lUpLoad = FTPPUTFILE( oFtp:hFTP, cFile, cWhere + cFile, FTP_TRANSFER_TYPE_BINARY, 0 )
oFtp:End()
ENDIF
oInternet:End()
ENDIF
RETURN lUploadRe: FTPPutFile() requires too minutes to upload
How long does it take for the function to return false? Because that's the critical point; it makes me wait for many minutes.
- Enrico Maria Giordano
- Posts: 9054
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact: