Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Developer
daniellorenzin
Posts: 13
Registered: ‎06-24-2010
My Device: Bold 9700

Loading data from FTP in simulator

Hello,

 

I'm trying to load data from a public ftp server using a HTTPService or even a URLLoader. 

 

When I run in the normal debugger I get data, but when I run within the simulator I'm getting nothing.

 

Yet if it's a normal http site, it works fine. Has FTP been blocked? 

 

Thanks

 

Daniel

Developer
willyyr
Posts: 229
Registered: ‎08-14-2009
My Device: Bold 9900, DevAlpha A

Re: Loading data from FTP in simulator

It'd be easier to help you if you posted the actual part of the code where you are trying to access the ftp. I guess with normal debugger you mean debuggin as a Desktop Air app. If so did you make sure your network setup allows the pb sim to access the internet?

 

Sorry just saw it's working when normal http site... My bad.

Willy R.
-
If my post solved your problem, make it easier for others to find by Accepting it as a solution or provide a Kudo if it was helpful for you. Thanks.
New Developer
daniellorenzin
Posts: 13
Registered: ‎06-24-2010
My Device: Bold 9700

Re: Loading data from FTP in simulator

Thanks for the reply, i'm just using a simple URLLoader at this stage with a GET.

 

I guess i want confirmation if port 21 is block on the playbook or if it's a limitation of the simulator.

 

Is there any documentation of what they are supporting??

 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Loading data from FTP in simulator

[ Edited ]

daniellorenzin wrote:

I'm trying to load data from a public ftp server using a HTTPService or even a URLLoader. 

 

When I run in the normal debugger I get data, but when I run within the simulator I'm getting nothing.

 

Yet if it's a normal http site, it works fine. Has FTP been blocked? 


Are you certain that with the "normal debugger" it's working?  (and what's "normal" mean?  do you mean when running on your host machine using ADL?)

 

And are you certain that when it's working, you're actually using FTP and not just talking with HTTP to a site that supports both HTTP and FTP?

 

I see nothing in the documentation to suggest that either mx.rpc.http.HTTPService or flash.net.URLLoader will work with FTP.  (Edit: there's nothing in the docs, but apparently URLLoader does have some sort of support for FTP.  See my follow-up below.)

 

HTTP and FTP are totally different protocols.... no real relationship between them.

 

Furthermore, in a subsequent post you mention you're "using a simple URLLoader at this stage with a GET".  While both HTTP and FTP have a "GET" command, they are again completely unrelated in terms of how they are implemented.  It seems very unlikely (given what I in search results) that this is going to work for you, or that you're really using FTP when you run in the "normal debugger".

 

Lastly, I know the simulator does not block outgoing connections on port 21.

 

If you want to talk to FTP, you should probably find a third-party library that provides an FTP client for ActionScript3.  It would build on top of flash.net.Socket, and that certainly would work.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
daniellorenzin
Posts: 13
Registered: ‎06-24-2010
My Device: Bold 9700

Re: Loading data from FTP in simulator

[ Edited ]

With the normal debugger "ADL" the program is able to download a text document and then extract the data into the objects i have created.

 

When i run within the simulator with the same code it is not throwing an error, but is only returning an empty buffer. Yet no failure.

 

The service I'm hitting is only over the FTP channel, they don't support HTTP, and I'm specifying the complete address including ftp://.

 

I haven't had a lot to do with flex and FTP as all my work involves xml via http calls.

 

Thanks for the tip about ftp libs, i'll have a look for some, I just a little unsure as it runs fine in ADL and fails to get any data in the simulator.

 

Daniel

 

ps. The code i was using was the following

var loader:URLLoader = new URLLoader();

 var request:URLRequest = new URLRequest("ftp://ftp2.bom.gov.au/anon/gen/fwo/IDA00001.dat");

request.method = URLRequestMethod.GET;

 

 //setting all of the error handling for the web request

loader.addEventListener(Event.COMPLETE, responder.result);

loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

 

loader.load(request);

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Loading data from FTP in simulator

Okay, I've confirmed that in spite of there being basically no documentation to support it that I can find, the URLLoader class does implement support for FTP.

 

I used tcpdump on my server to monitor traffic and can see the connection getting established and commands issued to retrieve the file.

 

I can also confirm that when doing this from the simulator, I get an empty response.  That is, event.target.data is the empty string "".  I haven't dug into the full TCP packet data to see whether it's somehow not requesting the file correctly, not getting the file correctly, or is getting everything but simply ignoring the results.

 

The odd thing is that when I do this from ADL I actually get different results than you or the simulator.  I just get an IOError after a timeout (haven't checked the details yet), and no sign of FTP traffic.

 

Anyway, our results suggest there is a problem in the simulator with the FTP support in URLLoader.  You should probably create an issue in the tracker to report it (and maybe post a followup here with the ticket id so others can find the resolution when it's resolved).


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
daniellorenzin
Posts: 13
Registered: ‎06-24-2010
My Device: Bold 9700

Re: Loading data from FTP in simulator

Thanks again, bug submitted. 

 

TABLET-50

 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Loading data from FTP in simulator

Addendum: both loader.bytesTotal and bytesLoaded show 0 as well, even when I see in the "tcpdump" output that the full file (in my case a mere 82 bytes) has been transferred successfully.  Here's a portion of the full transcript as seen with "tcpdump port 21 -X -s 256".  The filename is FFFpatient.txt and the file is 82 bytes of ASCII 0s and 1s separated by spaces.

 

 

07:07:20.256127 IP 192.168.7.173.65480 > 208.74.209.137.21: P 72:93(21) ack 603 win 33580
        0x0000:  4500 003d 5d5b 4000 4006 7336 c0a8 07ad  E..=][@.@.s6....
        0x0010:  d04a d189 ffc8 0015 f149 2e82 03a0 abdb  .J.......I......
        0x0020:  5018 832c 2f11 0000 5245 5452 2046 4646  P..,/...RETR.FFF
        0x0030:  7061 7469 656e 742e 7478 740d 0a         patient.txt..
07:07:20.257352 IP 208.74.209.137.21 > 192.168.7.173.65480: P 603:633(30) ack 93 win 1460
        0x0000:  4510 0046 f413 4000 4006 dc64 d04a d189  E..F..@.@..d.J..
        0x0010:  c0a8 07ad 0015 ffc8 03a0 abdb f149 2e97  .............I..
        0x0020:  5018 05b4 8983 0000 3135 3020 4163 6365  P.......150.Acce
        0x0030:  7074 6564 2064 6174 6120 636f 6e6e 6563  pted.data.connec
        0x0040:  7469 6f6e 0d0a                           tion..
07:07:20.257756 IP 192.168.7.40.58154 > 192.168.7.173.65478: FP 1:83(82) ack 1 win 1460
        0x0000:  4508 007a f61f 4000 4006 b430 c0a8 0728  E..z..@.@..0...(
        0x0010:  c0a8 07ad e32a ffc6 0391 ab92 f3fa 1107  .....*..........
        0x0020:  5019 05b4 c10e 0000 3009 3009 3009 3009  P.......0.0.0.0.
        0x0030:  3009 3009 3009 3009 3109 3109 3009 3109  0.0.0.0.1.1.0.1.
        0x0040:  3109 3009 3009 3109 3009 3109 3109 3009  1.0.0.1.0.1.1.0.
        0x0050:  3109 3009 3009 3009 3009 3009 3109 3109  1.0.0.0.0.0.1.1.
        0x0060:  3109 3009 3109 3009 3009 3009 3009 3109  1.0.1.0.0.0.0.1.
        0x0070:  3109 3009 3109 3109 300a                 1.0.1.1.0.
07:07:20.258190 IP 208.74.209.137.21 > 192.168.7.173.65480: P 633:729(96) ack 93 win 1460
        0x0000:  4510 0088 f414 4000 4006 dc21 d04a d189  E.....@.@..!.J..
        0x0010:  c0a8 07ad 0015 ffc8 03a0 abf9 f149 2e97  .............I..
        0x0020:  5018 05b4 e5d0 0000 3232 362d 4669 6c65  P.......226-File
        0x0030:  2073 7563 6365 7373 6675 6c6c 7920 7472  .successfully.tr
        0x0040:  616e 7366 6572 7265 640d 0a32 3236 2030  ansferred..226.0
        0x0050:  2e30 3030 2073 6563 6f6e 6473 2028 6d65  .000.seconds.(me
        0x0060:  6173 7572 6564 2068 6572 6529 2c20 3139  asured.here),.19
        0x0070:  392e 3231 204b 6279 7465 7320 7065 7220  9.21.Kbytes.per.
        0x0080:  7365 636f 6e64 0d0a                      second..
...
07:07:32.185731 IP 208.74.209.137.21 > 192.168.7.173.65480: P 729:742(13) ack 94 win 1460
        0x0000:  4510 0035 f415 4000 4006 dc73 d04a d189  E..5..@.@..s.J..
        0x0010:  c0a8 07ad 0015 ffc8 03a0 ac59 f149 2e98  ...........Y.I..
        0x0020:  5018 05b4 a675 0000 3232 3620 4c6f 676f  P....u..226.Logo
        0x0030:  7574 2e0d 0a                             ut...

 

 

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Loading data from FTP in simulator

I tried capturing the session using @daniellorenzin's Aussie gov't site as well,and I can see the data transfer this time as well, though it's not in the "control" channel (on port 21) as with regular PASV mode.  The session actually enters "Extended Passive mode", which I'd never heard of before.  (See section 3 on "The EPSV Command" in http://www.ietf.org/rfc/rfc2428.txt)

 

Anyway, monitoring the full session I do see the complete transfer of data, so again everything seems to be working except the data is just discarded for some reason after the transfer is complete.  A snippet is below as proof.

 

By the way @daniellorenzin,  watch out for showers and thunderstorms Down Under today :-)

 

07:48:46.933705 IP 134.178.63.130.62497 > 192.168.7.173.65472: . 1461:2921(1460) ack 1 win 46
        0x0000:  4500 05dc fd71 4000 2406 c520 86b2 3f82  E....q@.$.....?.
        0x0010:  c0a8 07ad f421 ffc0 5e2d f91b 99e0 0a3f  .....!..^-.....?
        0x0020:  5010 002e 3932 0000 5368 6f77 6572 7320  P...92..Showers.
        0x0030:  616e 6420 7374 6f72 6d73 2e23 5368 6f77  and.storms.#Show
        0x0040:  6572 7320 616e 6420 7374 6f72 6d73 2e23  ers.and.storms.#
        0x0050:  5368 6f77 6572 206f 7220 7477 6f20 6465  Shower.or.two.de
        0x0060:  7665 6c6f 7069 6e67 2e23 506f 7373 6962  veloping.#Possib
        0x0070:  6c65 2073 686f 7765 722e 2353 686f 7765  le.shower.#Showe
        0x0080:  7220 6f72 2074 776f 2e23 5368 6f77 6572  r.or.two.#Shower
        0x0090:  206f 7220 7477 6f2e 234d 6f73 746c 7920  .or.two.#Mostly.
        0x00a0:  7375 6e6e 792e 230a 3036 3631 3132 2342  sunny.#.066112#B
        0x00b0:  6f6e 6469 234e 5357 2332 3031 3130 3132  ondi#NSW#2011012
        0x00c0:  3123 3230 3131 3031 3231 2331 3535 3532  1#20110121#15552
        0x00d0:  3023 2323 3232 2332 3523 3231 2332 3523  0###22#25#21#25#
        0x00e0:  3232 2333 3123 3234 2332 3823            22#31#24#28#

 

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: Loading data from FTP in simulator

 


daniellorenzin wrote:

Thanks again, bug submitted. 

 

TABLET-50 


 

Any chance you could add a note to that report?  I would, but the way they've set up the tracker they seem to like hiding new issues for quite a while for reasons unknown.

 

I wrote an article about this and "John" commented on it, noting "I can confirm the same thing happens on AIR Android. I'm testing on a Galaxy S. I can get and trace the BOM data fine on my desktop app. On the android, at Event.COMPLETE, the data is empty. I guess the AIR API is not complete or in any way comparable to AIR on the desktop."

 

So it's apparently not limited to AIR on QNX.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!