It is currently Thu Oct 01, 2020 1:10 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: PB.Ex FTP (Windows)
PostPosted: Sat Jul 27, 2019 4:35 pm 
Offline
Moderator
Moderator

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1112
Location: Gernsbach (Germany)
It's the current version. I forgot to change the version comment. :oops:

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: PB.Ex FTP (Windows)
PostPosted: Sun Jul 28, 2019 9:03 am 
Offline
Enthusiast
Enthusiast

Joined: Fri Oct 16, 2009 10:12 am
Posts: 684
Location: BE
RSBasic, already a thanks for this.
I will need it probably one of these as you noticed.
Still have a lot to figure out.

_________________
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.


Top
 Profile  
Reply with quote  
 Post subject: Re: PB.Ex FTP (Windows)
PostPosted: Tue Sep 10, 2019 4:35 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jul 03, 2003 6:53 pm
Posts: 1320
Location: England
RSBasic wrote:
PureBasic can neither SFTP (SSH File Transfer Protocol) nor FTPS (FTP over SSL/TLS). With this library this is possible.

Thank you, RSBasic :!:
This library was a big help for me today :D


Top
 Profile  
Reply with quote  
 Post subject: Re: PB.Ex FTP (Windows)
PostPosted: Tue Jan 07, 2020 2:42 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Feb 16, 2006 1:41 am
Posts: 180
Location: New Zealand
Better late than never, but thanks heaps RSBasic, this is exactly what I need right now.

Now all I have to do is download it through our (work) ISP who flags your site as having a malicious reputation....grrrrrrrrrrrrrrrr!!!!!!!!!!!!!!!

Regards,
Amundo

_________________
Win8.1, PB5.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes


Top
 Profile  
Reply with quote  
 Post subject: Re: PB.Ex FTP (Windows)
PostPosted: Mon Jun 08, 2020 3:10 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Oct 21, 2010 9:46 pm
Posts: 138
Hi,

I'm trying to use this library in something, but am running into a problem where the first connection to a server works, but later attempts to reconnect to that server fail, and this failure continues until logoff (i.e. quitting and restarting the program doesn't help)

Specifically, I have a process that will periodically have data to upload via FTPS. For what this process needs to do, it doesn't need to look at what's in the FTP server folder, so is not using ExamineFTPDirectoryEx(), but going straight to uploading its files. This is partly because it doesn't need to know what's there, but also because the folder its uploading to may have a high filecount, so enumerating the contents would be slow.

Another process is looking at the upload location (not by FTP) to process the files that appear there. To avoid file locking issues between the upload and processing systems, I upload as a temporary file name and then rename once the upload completes. As a precaution, I attempt to delete any existing file of the intended final or temporary name before uploading. (This is probably not relevant to the problem, but more of an explanation for why the code below is doing what it does.)

So, the code goes something like this:

Code:
errorout$=Space(128)
ftphnd=OpenFTPEx(#PB_Any, #PBEx_FTP_Protocol_FTPS_Explicit, server$, 21, user$, pass$, #PB_UTF8, @errorout$)
If ftphnd
  Debug "Got ftp handle: "+Str(ftphnd)
 
  ; Delete any existing real or temp file. Probably none, so ignore errors.
  DeleteFTPFileEx(ftphnd, desttmp$, @errorout$)
  DeleteFTPFileEx(ftphnd, destfinal$, @errorout$)
 
  ; Upload to temp file then rename.
  errorout$=Space(128)
  If SendFTPFileEx(ftphnd, src$, desttmp$, #False, @errorout$)
    Debug "ftp upload successful, renaming destination."
    errorout$=Space(128)
    If RenameFTPFileEx(ftphnd, desttmp$, destfinal$, @errorout$)
      Debug "ftp rename successful, deleting local file"
      DeleteFile(src$)
    Else
      Debug "Unable to rename file"+desttmp$+" : "+Trim(errorout$)
    EndIf
  Else
    Debug "Unable to upload file: "+src$+" : "+Trim(errorout$)
  EndIf
 
  Debug "Closing FTP connection"
  errorout$=Space(128)
  result=CloseFTPEx(ftphnd, @errorout$)
  Debug "Result: "+Str(result)+" : "+Trim(errorout$)
  ftphnd=0
Else
  Debug "Failed to connect to FTP : "+Trim(errorout$)
EndIf


This all works for the first upload attempt, the file(s) are uploaded correctly and all is well. CloseFTPEx() returns success.

Subsequent attempts result in OpenFTPEx() returning 0 and setting errorout$ to "Error: Timed out trying to read data from the socket stream!". (I.e. this is reported by the "Failed to connect" line at the end.)

All subsequent attempts to connect fail with this error. Closing the PB application and restarting it doesn't fix it (!) (meaning whatever is stuck is not a PB handle but something more fundamental).

Logging off and back on again clears it (but again, for only one upload). Rebooting also fixes it for one upload.

This looks like something from the first upload is not being closed properly, but I don't see anything I'm missing there. I have a CloseFTPEx() that corresponds with the OpenFTPEx(), am not using IsAsynchron anywhere, and there are no directories I need to finish.

Underlying OS is Win10 1809 (build 17763) 64bit. FTP server is XLightFTPd on Windows. Files being transferred are relatively small (few KB, typically), and are UTF8 text.

Googling the error message leads to pages about the FluentFTP library, such as these:

https://github.com/robinrodricks/FluentFTP/issues/122

https://github.com/robinrodricks/FluentFTP/issues/124

But the suggestions there don't seem to offer anything I can try from within PB.

Any ideas?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye