Re: libUrlFtpUploadFile - reuse open sockets?

2009-04-15 Thread Bernard Devlin
My initial thought on seeing Phil's posting was that it might be a
server setting and thus not something one can control at the client.

I thought this because a couple of weeks ago I stumbled upon a
discussion where SSH (for some user) was creating a new connection for
each command sent to the server.  It was fixed by changing a server
setting so that SSH re-used connections.  At least that's how my
memory of the discussion.

Bernard

On Wed, Apr 15, 2009 at 4:23 AM, Sarah Reichelt
sarah.reich...@gmail.com wrote:
 While using libUrlFtpUploadFile to upload a bunch of files to a server, I
 find that libUrlFtpUploadFile opens a new socket for each upload. Even using
 a callback message to start a new one when the current one finishes, I get a
 max number of connections message back from the server when the server's
 max number is reached. After this, the next few upload attempts fail due to
 max number of connections; then as the open connections time out, new files
 can successfully upload again.

 I had this problem with a particular server. I always get the new
 connection with every command, but not all servers mind this.
 My solution was to use libURLSetFTPStopTime and set it to a very small
 number. This supposedly allows re-use of an existing connection, but
 in my experience all it does it keep one open while still opening
 another. If you set it to a very low number, then connections will
 close more rapidly, so you should not reach the maximum number of
 connections allowed.

 HTH,
 Sarah
 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: libUrlFtpUploadFile - reuse open sockets?

2009-04-15 Thread Jim Bufalini
Hi Sarah,

Rather than gambling and waiting for a timeout to occur and, assuming there
aren't any other sockets open for other purposes, couldn't Phil just issue a
resetAll in his uploadEnded command? This forces the close of all sockets
and a reset of everything in liburl. Otherwise, a close of the specific
socket used for the upload could be used, which socket could be determined
by checking the openSockets prior to and immediately after the
libUrlFtpUploadFile command.

I've never run into this limits problem personally but have used resetAll
and close socket.

Aloha from Hawaii,

Jim Bufalini

 I had this problem with a particular server. I always get the new
 connection with every command, but not all servers mind this.
 My solution was to use libURLSetFTPStopTime and set it to a very small
 number. This supposedly allows re-use of an existing connection, but
 in my experience all it does it keep one open while still opening
 another. If you set it to a very low number, then connections will
 close more rapidly, so you should not reach the maximum number of
 connections allowed.
 
 HTH,
 Sarah
 ___
 use-revolution mailing list
 use-revolution@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


libUrlFtpUploadFile - reuse open sockets?

2009-04-14 Thread Phil Davis

Howdy -

While using libUrlFtpUploadFile to upload a bunch of files to a server, 
I find that libUrlFtpUploadFile opens a new socket for each upload. Even 
using a callback message to start a new one when the current one 
finishes, I get a max number of connections message back from the 
server when the server's max number is reached. After this, the next few 
upload attempts fail due to max number of connections; then as the open 
connections time out, new files can successfully upload again.


So... I want to know:

1) Does FTP require a new socket for each upload?

2) If not, how do I tell libUrlFtpUploadFile to reuse an existing open 
socket for the next upload?


3) Is there something else I'm missing? Am I making things more 
complicated than they need to be? I have a nagging suspicion along this 
line...



Here's how my code is structured:

on uploadMyFile pLocalFile, pServerPath
 libUrlFtpUploadFile pLocalFile,pServerPath,uploadEnded
end uploadMyFile

on uploadEnded pUrl, pStatus
 put pUrl  tab  pStatus  cr after fld callbackParams
 put nextFileFromList() into p1
 put nextServerPath() into p2
 send (uploadMyFile  p1  comma  p2) to me in 6 ticks
end uploadEnded


Many thanks for your help.
--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: libUrlFtpUploadFile - reuse open sockets?

2009-04-14 Thread Jim Bufalini
Hi Phil,


 While using libUrlFtpUploadFile to upload a bunch of files to a server,
 I find that libUrlFtpUploadFile opens a new socket for each upload.
 Even
 using a callback message to start a new one when the current one
 finishes, I get a max number of connections message back from the
 server when the server's max number is reached. After this, the next
 few
 upload attempts fail due to max number of connections; then as the open
 connections time out, new files can successfully upload again.
 
 So... I want to know:
 
 1) Does FTP require a new socket for each upload?
 
 2) If not, how do I tell libUrlFtpUploadFile to reuse an existing open
 socket for the next upload?
 
 3) Is there something else I'm missing? Am I making things more
 complicated than they need to be? I have a nagging suspicion along this
 line...
 
 
 Here's how my code is structured:
 
 on uploadMyFile pLocalFile, pServerPath
   libUrlFtpUploadFile pLocalFile,pServerPath,uploadEnded
 end uploadMyFile
 
 on uploadEnded pUrl, pStatus
   put pUrl  tab  pStatus  cr after fld callbackParams
   put nextFileFromList() into p1
   put nextServerPath() into p2
   send (uploadMyFile  p1  comma  p2) to me in 6 ticks
 end uploadEnded
 

Since it doesn't appear that you are using the callback except to know the
upload ended and assuming these files are not huge and you don't need to do
anything else during the upload like show a progress bar or other
processing, you can just use:

Put binfile: before pLocalFile
Put URL pLocalFile into URL pServerPath

Unlike libUrlFtpUploadFile, a put URL is blocking, which means your
upLoadMyFile command is paused until the upload completes. If there is an
error, it will be returned in *the result* and you can handle your next
logic in the same handler.

I believe that because it's blocking, the socket is closed after the
upload, but someone else can/will correct me on this if I am wrong. ;-)

Aloha from Hawaii,

Jim Bufalini




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: libUrlFtpUploadFile - reuse open sockets?

2009-04-14 Thread Jim Ault
I think that using a callback handler you can detect the 100% complete  
message from the server,
then issue a 'QUIT' to close the connection immediately, then after  
getting the 'GOODBYE', start the next upload.


I have not done this in practice that I know of (accidents do happen  
and things work without you knowing why).


Jim Ault
Las Veagas
On Apr 14, 2009, at 3:34 PM, Phil Davis wrote:


Howdy -

While using libUrlFtpUploadFile to upload a bunch of files to a  
server, I find that libUrlFtpUploadFile opens a new socket for each  
upload. Even using a callback message to start a new one when the  
current one finishes, I get a max number of connections message  
back from the server when the server's max number is reached. After  
this, the next few upload attempts fail due to max number of  
connections; then as the open connections time out, new files can  
successfully upload again.


So... I want to know:

1) Does FTP require a new socket for each upload?

2) If not, how do I tell libUrlFtpUploadFile to reuse an existing  
open socket for the next upload?


3) Is there something else I'm missing? Am I making things more  
complicated than they need to be? I have a nagging suspicion along  
this line...



Here's how my code is structured:

on uploadMyFile pLocalFile, pServerPath
libUrlFtpUploadFile pLocalFile,pServerPath,uploadEnded
end uploadMyFile

on uploadEnded pUrl, pStatus
put pUrl  tab  pStatus  cr after fld callbackParams
put nextFileFromList() into p1
put nextServerPath() into p2
send (uploadMyFile  p1  comma  p2) to me in 6 ticks
end uploadEnded


Many thanks for your help.
--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: libUrlFtpUploadFile - reuse open sockets?

2009-04-14 Thread Phil Davis

Hi Jim B  Jim A,

Thanks for the replies.

Actually I'm using libUrlFtpUploadFile because some of the files are 
movies (some  100mb), so I don't want to use a blocking command.


The more I think about this, the more I believe it's a libUrl bug. If 
socket reuse works for download (which I believe it does), it should 
work for upload... Of course my argument is from a desire for the beauty 
of symmetry without regard to what's possible - which is how many good 
things come into being  ;o)


I have a 2-part workaround:

on mouseUp
  ### WORKAROUND PART 1
  put 10 into xServerMax
  -- I know the above number from experience;
  -- would rather ask FTP server for max
  -- but don't know an FTP command for it
  libUrlSetFTPStopTime 1 -- set the socket timeout to 1 sec
  ### WORKAROUND PART1 - end

  uploadMyFile tFirstLocalFile, tFirstServerPath
end mouseUp


on uploadMyFile pLocalFile, pServerPath
  libUrlFtpUploadFile pLocalFile,pServerPath,uploadEnded
end uploadMyFile


on uploadEnded pUrl, pStatus
  put pUrl  tab  pStatus  cr after fld callbackParams
  put nextFileFromList() into p1
  put nextServerPath() into p2

  ### WORKAROUND PART 2
  repeat until (the number of lines in the openSockets  xServerMax)
 wait 1 tick with messages
  end repeat
  ### WORKAROUND PART 2 - end

  send (uploadMyFile  p1  comma  p2) to me in 1 ticks
end uploadEnded




Phil


Jim Bufalini wrote:

Hi Phil,

  

While using libUrlFtpUploadFile to upload a bunch of files to a server,
I find that libUrlFtpUploadFile opens a new socket for each upload.
Even
using a callback message to start a new one when the current one
finishes, I get a max number of connections message back from the
server when the server's max number is reached. After this, the next
few
upload attempts fail due to max number of connections; then as the open
connections time out, new files can successfully upload again.

So... I want to know:

1) Does FTP require a new socket for each upload?

2) If not, how do I tell libUrlFtpUploadFile to reuse an existing open
socket for the next upload?

3) Is there something else I'm missing? Am I making things more
complicated than they need to be? I have a nagging suspicion along this
line...


Here's how my code is structured:

on uploadMyFile pLocalFile, pServerPath
  libUrlFtpUploadFile pLocalFile,pServerPath,uploadEnded
end uploadMyFile

on uploadEnded pUrl, pStatus
  put pUrl  tab  pStatus  cr after fld callbackParams
  put nextFileFromList() into p1
  put nextServerPath() into p2
  send (uploadMyFile  p1  comma  p2) to me in 6 ticks
end uploadEnded




Since it doesn't appear that you are using the callback except to know the
upload ended and assuming these files are not huge and you don't need to do
anything else during the upload like show a progress bar or other
processing, you can just use:

Put binfile: before pLocalFile
Put URL pLocalFile into URL pServerPath

Unlike libUrlFtpUploadFile, a put URL is blocking, which means your
upLoadMyFile command is paused until the upload completes. If there is an
error, it will be returned in *the result* and you can handle your next
logic in the same handler.

I believe that because it's blocking, the socket is closed after the
upload, but someone else can/will correct me on this if I am wrong. ;-)

Aloha from Hawaii,

Jim Bufalini




___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

  


--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: libUrlFtpUploadFile - reuse open sockets?

2009-04-14 Thread Sarah Reichelt
 While using libUrlFtpUploadFile to upload a bunch of files to a server, I
 find that libUrlFtpUploadFile opens a new socket for each upload. Even using
 a callback message to start a new one when the current one finishes, I get a
 max number of connections message back from the server when the server's
 max number is reached. After this, the next few upload attempts fail due to
 max number of connections; then as the open connections time out, new files
 can successfully upload again.

I had this problem with a particular server. I always get the new
connection with every command, but not all servers mind this.
My solution was to use libURLSetFTPStopTime and set it to a very small
number. This supposedly allows re-use of an existing connection, but
in my experience all it does it keep one open while still opening
another. If you set it to a very low number, then connections will
close more rapidly, so you should not reach the maximum number of
connections allowed.

HTH,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: libUrlFtpUploadFile - reuse open sockets?

2009-04-14 Thread Phil Davis

Thanks Sarah.

Sarah Reichelt wrote:

While using libUrlFtpUploadFile to upload a bunch of files to a server, I
find that libUrlFtpUploadFile opens a new socket for each upload. Even using
a callback message to start a new one when the current one finishes, I get a
max number of connections message back from the server when the server's
max number is reached. After this, the next few upload attempts fail due to
max number of connections; then as the open connections time out, new files
can successfully upload again.



I had this problem with a particular server. I always get the new
connection with every command, but not all servers mind this.
My solution was to use libURLSetFTPStopTime and set it to a very small
number. This supposedly allows re-use of an existing connection, but
in my experience all it does it keep one open while still opening
another. If you set it to a very low number, then connections will
close more rapidly, so you should not reach the maximum number of
connections allowed.

HTH,
Sarah
  

--
Phil Davis

PDS Labs
Professional Software Development
http://pdslabs.net

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution