Sunday, April 4, 2010

Flex FTP and socket error #2031

Hi to all!

I'm trying to develop a FTP client in Flex/Air with socket (...whatelse !?!?)

I can connect to the FTP server and authenticate. Then I switch to passive mode sending the ''PASV'' ftp command.

In response i receive the data port on which I will (...well...actually....on which I would like to....) transfer the files. And here comew the trouble.

I create a new socket wich attempts to connect?on the port the server told me, it stands still for some moments and give me the socket error #2031.

Below the complete error (URL's IP replaced with 'xx.xx.xx.xx'):

[IOErrorEvent type=''ioError'' bubbles=false cancelable=false eventPhase=2 text=''Error #2031: Socket Error URL: xx.xx.xx.xx'' errorID=2031]

I've tried to google around but i didn't find anything useful more than Adobe Flex Socket reference (which doesn't even talk about #2031 error )

I've also tried to perform FTP task with the maliboo FTP lib but it behaves the same as mentioned before.

Any ideas,suggestions or solutions?

Thanks in advance guys for the attention!

Best regards!

Luca

P.S. :

Below the code I've used:

%26lt;?xml version=''1.0'' encoding=''utf-8''?%26gt;
%26lt;mx:WindowedApplication xmlns:mx=''http://www.adobe.com/2006/mxml''?span>
layout=''vertical'' initialize=''init()''%26gt;
%26lt;mx:Script%26gt;
?%26lt;![CDATA[
?
?private var sCommand:Socket
?private var sData:Socket
?
?private function init():void{
?sCommand=new Socket(''xx.xx.xx.xx'',21);
?sCommand.addEventListener(ProgressEvent.SOCKET_DATA,commandResponse)
?sCommand.addEventListener(IOErrorEvent.IO_ERROR, commandError);
?sCommand.writeUTFBytes(''USER xxxxxx\n'');
?sCommand.flush();
?sCommand.writeUTFBytes(''PASS xxxxxxx\n'');
?sCommand.flush();
?sCommand.writeUTFBytes(''CWD /mydirectory/\n'');
?sCommand.flush();
?sCommand.writeUTFBytes(''PASV\n'');
?sCommand.flush();
?}
?
?private function commandResponse(e:ProgressEvent):void{
?var command_resp:String=sCommand.readUTFBytes(sCommand.bytesAvailable)
?if(command_resp.indexOf(''227'')%26gt;-1){
?
?var temp:String = command_resp.substring(command_resp.indexOf(''('')+1,command_resp.indexOf('')''));
?var data_channel_temp:Array = temp.split('','');
?var data_channel_ip:String=data_channel_temp.slice(0,4).join('.')
?var data_channel_port:int=parseInt(data_channel_temp[4])*256+parseInt(data_channel_ temp[5])
?trace(data_channel_ip+'' ''+data_channel_port)
?
?sData=new Socket(data_channel_ip,data_channel_port)?//here it starts to stand still and after a while it crash with error #2031
?sData.addEventListener(ProgressEvent.SOCKET_DATA,dataResponse)
?sData.addEventListener(IOErrorEvent.IO_ERROR, dataError);
?}
?trace(''command ''+command_resp)
?}
?
?private function commandError(e:IOErrorEvent):void{
?trace(''command -%26gt; ''+e.text)
?}
?
?private function dataResponse(e:ProgressEvent):void{
?trace('data '+e)
?}
?
?private function dataError(e:IOErrorEvent):void{
?trace('data error ' +e)
?}
?]]%26gt;
%26lt;/mx:Script%26gt;
%26lt;/mx:WindowedApplication%26gt;

Flex FTP and socket error #2031

How many different FTP servers have you used to try out this? for me it seems problem in the FTP server side..

Flex FTP and socket error #2031

First, thanks for your reply!

I've first tried on the main hosting platform we use and doesn't work.

This morning I've also tried on another low-cost hosting platofrm and it works quite well (I can get to make the data connection in passive mode and retrieve the file list).

The weird thing is?that since our main hosting platform has changed the server the flex ftp doesn't work anymoe. Before, all worked well.

If is a problem of FTP server which colud be the cause?

Could be due to a wrong configuration?Some firewall?

Another strange thing is that other FTP client such Fetch or FileZilla connects well without any problem.Maybe flex socket lack of something?

Below some information about the server (this is the FileZilla log):

220---------- Welcome to Pure-FTPd [TLS] ----------

[...]

SYST
?215 UNIX Type: L8

FEAT
211-Extensions supported:
?EPRT
IDLE
MDTM
SIZE
REST STREAM
?MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*;
?MLSD

ESTP
PASV
?EPSV
?SPSV
?ESTA
?AUTH TLS
?PBSZ
PROT

Let me Know!!!

Best regards!

fetch feature sets from both FTP servers and compare them to eliminate the possible difference.

also please mark helpful posts to ease up others to find same looking solutions faster, thanks.

Well, i've tried to figure out the differences but the 2 server give different response (one is more verbose than the other) so i cannot see which differences occur between the two server. The only thing that i found is that both server run on ProFTPd

I cannot understand why the socket gets to connect and authenticate, but when it's time to open the passive connection the sockets (on which the date should flow) fails with error#2031.

Does AIR have some limitation about the port range which socket can connect?

Thansk so much for the help!

Hi to all!!!

After some painful hours of research I've achieved what has changed on the server.

The main difference between the old server and the new one is that the previous had a dedicated ip address for each domain while the new one is a shared ip hosting solution.

Do you think this could affect the ftp library to crash or conduce to throw the famous #2031 socket error?

As said previously the weird thing is that other ftp client such filezilla or fetch work fine.

Thanks in advance for tha patience!!!

Best regards!

No comments:

Post a Comment