truncated responses, also multple requests in parallel

37 views
Skip to first unread message

steve

unread,
Feb 22, 2009, 6:44:20 PM2/22/09
to AS3 HttpClient
Had just posted (think it went to gabe not the group) about gettng
truncated response data even using onDataComplete (with sequential
requests). Found wasn't getting content length headers from the
server I was using. Using code from issue 4 comment 2
http://code.google.com/p/as3httpclientlib/issues/detail?id=4 solved
the truncated response although got arg mismatch at runtime on the
event clone in onClose, commented out this dispatch for now

What is the best way to do multiple requests in parallel (say GET/GET,
etc.) from same client with the HttpClient class in as3httpclientlib?
Separate HttpClient instances doesn't seem to work reqest Use same
HttpClient but use separate HttpDataListener per request?

env: windows vista x64, flash10+firefox 3.0.6, air 1.5, flexbuilder
3.0.2, flex sdk 3.2, latest as3atompub source adapted to work with
latest as3httpclientlib source, alfresco 3 cmis atom apis, working on
http://code.google.com/p/cmisspaces/ based on http://code.google.com/p/flexspaces/

Steve

gabe

unread,
Feb 22, 2009, 11:22:54 PM2/22/09
to AS3 HttpClient
Thanks, I added your patch for the case when there is no content-
length. It seems weird that web servers would choose not to send a
content-length (or at least use chunked encoding) but so be it.

Also, I double checked the arg mismatch, and I can't reproduce... I
did change the listener callback signatures awhile back to:

* - onClose(e:Event)
* - onComplete(e:HttpResponseEvent)
* - onConnect(e:HttpRequestEvent)
* - onData(e:HttpDataEvent)
* - onError(e:ErrorEvent)
* - onStatus(e:HttpStatusEvent)
* - onRequest(e:HttpRequestEvent)

Can you double check you are using the new callback signatures? I
tried to reproduce the arg mismatch on security error but after
updating to flash 10 standalone player I lost trace debugging which is
making my life difficult. Adobe seems to do that a lot though so I am
sort of used to it. I must be some kind of masochist or something. I
did however add a test where it tries to load a bad domain name and it
seems to get the IOErrorEvent ok, so it might be fixed.

Anyway, built a new swc 1.0.4 and put it up on the downloads page.

Thanks for feedback and help and sorry it took me so long to take a
look at this.

On Feb 22, 3:44 pm, steve <steverei...@integratedsemantics.com> wrote:
> Had just posted (think it went to gabe not the group) about gettng
> truncated response data even using onDataComplete (with sequential
> requests).  Found wasn't getting content length headers from the
> server I was using. Using code from issue 4 comment 2http://code.google.com/p/as3httpclientlib/issues/detail?id=4 solved

sreiner

unread,
Feb 23, 2009, 12:21:23 AM2/23/09
to AS3 HttpClient
Thanks Gabriel (for quick response, new version, and your Lib !)
Note the code patch in issue 4 was from s.podkowinski.
I will test this on a server that skips sending content-length headers
(and will look at the call back signatures, have been adapting
as3atompub that was originally using older as3httpclientlib code)
(as3atompub had listeners on the HttpClient not on a HttpDataListener
if that helps)

Did you have thoughts on
"What is the best way to do multiple requests in parallel (say GET/
GET,
etc.) from same client with the HttpClient class in as3httpclientlib?
Separate HttpClient instances doesn't seem to work reqest Use same
HttpClient but use separate HttpDataListener per request? "

Thanks,
Steve

gabe

unread,
Feb 23, 2009, 3:27:05 AM2/23/09
to AS3 HttpClient
I tested running multiple requests in parallel, though from separate
clients, and it seemed to work ok.

var client1:HttpClient = new HttpClient();
var client2:HttpClient = new HttpClient();

client1.listener.onComplete = function(event:Event):void {
Log.debug("On Complete #1");
};

client2.listener.onComplete = function(event:Event):void {
Log.debug("On Complete #2");
};

client1.get(new URI("http://www.google.com/"));
client2.get(new URI("http://www.yahoo.com/"));

Is there a reason you need to run in parallel from a single client?

On Feb 22, 9:21 pm, sreiner <steverei...@integratedsemantics.com>
wrote:

sreiner

unread,
Feb 24, 2009, 5:57:24 PM2/24/09
to AS3 HttpClient
1. the changes in the last build do work on server not returning
content-length
2. haven't tried the suggested parallel request code
(reason is for a Flex app using REST api with multiple views,
operations on multiple selected objects, all with the same server)
3. the thing with arg mismatch was I hadn't changed all the listeners
from as3autompub to use the new type of args coming back

4. noticed that a new thing in flash 10 / air 1.5 is a timeout on the
Socket (diff than the _timer:HttpTimer in HttpSocket. The onTimeout
ends up being converted in flash/flex to a security error and ends up
at HttpSocket::onSecurityError() Still can get and put data ok.

Gabe

unread,
Feb 24, 2009, 7:03:31 PM2/24/09
to as3-htt...@googlegroups.com
Thanks for trying it out and glad its working. I will take a look at #4.

sreiner

unread,
Feb 26, 2009, 4:06:48 AM2/26/09
to AS3 HttpClient

tried the parallel again with 2 HttpClients with same server.
Didn't work (maybe some interaction with no content length?)
Note: URLLoaders in parallel (with same requests I used with for
parallel HttpClients) with the server works.

Also:
the fix for no content-length in HttpSocket onClose() to send
onComplete()
will send onComplete() when not really complete ( since onTimeout,
onIOError(), onSecurityError() call close() )

sreiner

unread,
Feb 26, 2009, 7:12:33 PM2/26/09
to AS3 HttpClient
Gabe,

Parallel HttpClients does work for me too with the server I am using !
(problem saw on last post was on my side)

note: HttpSocket.as onClose()
needs check for null on "response" var

Steve

gabe

unread,
Mar 3, 2009, 2:20:02 AM3/3/09
to AS3 HttpClient
Applied some fixed for close. Hopefully nothing regressed with empty
content length.

New swc version 1.0.5 is up.

On Feb 26, 4:12 pm, sreiner <steverei...@integratedsemantics.com>
wrote:

sreiner

unread,
Mar 4, 2009, 7:18:15 PM3/4/09
to AS3 HttpClient
Gabe,
Thanks for fix. I switched to your latest source.
Two things:
1. In HttpSocket.as close() changes, needed to keep the check for
_socket.connected
otherwise get Error #2002: operation attempted on invalid socket
(am using flash 10 an AIR 1.5.1)
kept in change to not do flush, do dispatch instead calling onClose
2. forgot I had been running with the adding the Connection close
header in HttpRequest.as loadDefaultHeaders()
when I put it back in the Socket timer in flash 10 (not your timer)
calls onSecurityErrror for every Socket at the end
(for now in Socket.as onSecurityError I have the dispatchEvent
commented out for now
3. Note I set a breakpoint in HttpSocket.as sendRequest where there
was the jira bug comment, hit at least once
PS
I checked in my code using which uses as3httpclientlib when configured
for useSockets="true" in CMISSpacesConfig.xml
http://code.google.com/p/cmisspaces/
and it works with Alfresco content mgt/ECM server CMIS REST/Atompub
APIs (including its missing content lengths)
easy installer download w/ bundled Tomcat: http://wiki.alfresco.com/wiki/Download_Labs
Thanks,
Steve

Gabe

unread,
Mar 5, 2009, 3:27:37 AM3/5/09
to as3-htt...@googlegroups.com
Added the _socket.connected back in. Yeah, not sure why I assumed it
was ok to close a non-connected socket, and took it out.

I have seen the flash.net.Socket timer kick in when a connection never
gets closed? Though this seems like it should throw an onTimeout on
our side instead or erroring. One of these days I will get a
reproduceable setup. The security error sounds weird, though not
unexpected. This might be a byproduct of non closing connections (and
perhaps there is a security error if you try to have too many open
sockets at once?) ... This is a total guess though.

Gabe

unread,
Mar 5, 2009, 3:28:52 AM3/5/09
to as3-htt...@googlegroups.com
Oh and built a new swc version. Will checkout the cmisspaces! Thanks!
Reply all
Reply to author
Forward
0 new messages