#1
  1. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13

    Trouble with Passive Connections and FTP Raw Lists


    I have a script running that mirrors files in a certain directory to two file mirrors. It works perfectly with one of the mirrors, but with the other, I get a crapload of the same error, and it takes forever to execute:

    <br />
    <b>Warning</b>: Variable passed to next() is not an array or object in <b>/home/seriousc/files/cron.php</b> on line <b>95</b><br />
    <br />
    <b>Warning</b>: Variable passed to next() is not an array or object in <b>/home/seriousc/files/cron.php</b> on line <b>95</b><br />
    <br />
    <b>Warning</b>: Variable passed to next() is not an array or object in <b>/home/seriousc/files/cron.php</b> on line <b>95</b><br />
    <br />
    ...
    And from the script, lines 90-96:
    PHP Code:
    function DoRemote($dirname$onlydirs 0)
    {
        global 
    $conn$localdir$remotedir;

        
    $rlist ftp_rawlist($conn$dirname);
        while(
    $dir next($rlist))
        { 
    $dirname is the remote directory to get a list of, and $conn is the ftp connection. When I connected to the server with my FTP client and ran a LIST on it, I got the following:

    COMMAND:> LIST
    550 Cannot open passive data connection.
    So I tried turning passive mode off in the PHP script right after connecting. Still didn't work. What's wrong? It only does this for one of the mirrors - the other works perfectly.
  2. #2
  3. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    Use port instead of passv. BTW, if both you and server are behind firewall/router/proxy/etc which you don't control then just forget about mirrowing.
    And you know I mean that.
  4. #3
  5. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    port?
  6. #4
  7. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    port activates active connection rather then passive. Before you do that, connect to non working server and see which connection it uses - active or passive (just ls and see what it says)
    And you know I mean that.
  8. #5
  9. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    What's port? I didn't see it listed as a function...

    Something a bit odd...from the working server:

    COMMAND:> list
    425 Can't build data connection: Connection refused.

    For the non-working server:

    COMMAND:> list
    550 Cannot connect to XXX.XXX.XXX.XXX:4557 - Address already in use.
  10. #6
  11. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    'port' is not a function - it is way of connection (active that is) and is turned on/off with ftp_pasv() (sort of, depends from which side are you looking at it)

    About your errors. You're on nt4 or win2k, right? I could describe problem in more deatails, but in summary: CLI FTP client shipped with them does not support passive connections - you can get around it but rather just get another client.

    2 questions. What are you running as ftp servers and do you have firewalls/routers on either end?
    And you know I mean that.
  12. #7
  13. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    I'm not sure about firewalls/routers. The one that works is ftp.filefront.com and the one that doesn't is ftp.edome.net
  14. #8
  15. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    ftp.edome.net is working fine for both active and passive, can't check ftp.filefront.com as anonymous access is not allowed there.

    You don't run those servers, right? What os are you connecting from? As I mentioned nt4 and win2k might have problems with default ftp client.
    And you know I mean that.
  16. #9
  17. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    I'm connecting to them through CuteFTP on Windows 2000. My server is running Linux. And no, I don't run those
  18. #10
  19. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    This is actually php forum, y'know Is it still not working? May be max # of simultaneous users caused the problem... don't know and can't check as don't have login to filefront. Try using different client on different os, I'm 99% sure this isn't php's fault.
    And you know I mean that.
  20. #11
  21. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    I know this is a PHP forum. I posted what I'm using to connect on the server intself in the first post. I'm a little unclear on what you're saying.

    FileFront works, both locally and on the server via PHP. eDome doesn't work locally, which doesn't matter as much as the fact that it causes infinite warnings on the webserver. You mentioned something about port...I already mentioned that I'm using ftp_pasv($conn, false) before connecting to the server. An overview:

    -I connect
    -Turn off passive connections
    -Request a raw directory listing
    --FileFront works perfectly
    --eDome does not work. The odd thing is the script does what it's supposed to, but it spits out an infinite amount of errors and runs until manually halted.
  22. #12
  23. Mobbing Gangster
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Sep 2001
    Location
    "Best City" 2002 and 2003- Melbourne, Australia
    Posts
    4,912
    Rep Power
    33
    Ok, I can't say what's the error without seeing and trying the code. My best guess was active/passive connections, but that didn't work out too well, so I can't be much of further help.

    Just supress errors with @ if you don't like them (who does?), not going to solve the problem but makes it look better. Although you have to do something about infinite execution...
    And you know I mean that.
  24. #13
  25. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    I showed you the code in the first post....

    PHP Code:
        $rlist ftp_rawlist($conn$dirname);
        while(
    $dir next($rlist))
        { 
  26. #14
  27. No Profile Picture
    PHP Geek
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Posts
    37
    Rep Power
    13
    Nevermind...figured it out. Apparently ftp_rawlist() isn't standardized, so they were returning a different amount of information.

IMN logo majestic logo threadwatch logo seochat tools logo