tags:

views:

96

answers:

2

I'm connecting to an ftp server that I have no control over, and I'm pretty sure is using something old and outdated due to other issues I've run into.

I'm simply using this code in a loop to get all the files in a directory.

ftp_get($this->conn_id, $remote, $local, FTP_ASCII);

The first time all goes well, but after that I get this error thrown for each file I try to get: "There is already an active transaction"

I've tried both passive & active, as well as a nonblocking get with no luck. It's the exact same code I use to connect to other FTP servers and get files with no problem.

edit: Oddly enough, closing the connection, sleeping 3 seconds, and creating a new connection between each get yields the same results...

EDIT: Solved. Turns out that despite the errors, the files are still being got. The catch block was just catching the error so I didn't realize it. I'll just ignore that error.

A: 

It seems like "There is already an active transaction" may mean it is still transfering data when you try to use that connection again. Maybe use a sleep() function after puts and gets to give the transaction time to finish and see if that makes a difference. You shouldn't have to do that for php but I would try it just to rule it out as a possible issue.

I tried sleeping several seconds between files with no luck.
William
I would think several seconds would cover you if thats the problem but it depends how big the file you are transfering is. If its a big file it may need several minutes.
+1  A: 

Try using ftp_fget instead and saving the file before trying to get another one.

Levi Hackwith
No luck with fget
William
Dang. Can you post the entire code snippet your working with so we can see the logic surrounding the call to `ftp_get()`?
Levi Hackwith
Turns out I'm an idiot. It was actually mysql giving that error because of a stray line of code that was snuck in another method but still being caught in the same block. :(
William
It happens to the best of us. I'm not sure how to proceed in SO terms since you answered your own question. Anybody wanna help out here?
Levi Hackwith