call() right after connect() really a good idea?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

call() right after connect() really a good idea?

Felix E. Klee
I have a PyAMF gateway running on Google App Engine. However, the SWF
that connects to it sometimes doesn't get a response. That happened
various times with Opera. And when I finally decided to investigate
the problem, I couldn't reproduce it.

So, just to make sure, is the code below - in the document class -
alright? In particular, I wonder whether it's a good idea to
immediately after "connection.connect()" call "connection.call()".

- Felix

The code:

private var connection:NetConnection;
private var something = 1;

// Constructor of document class.
public function SomeClass() {
    connect();
    loadSomething();
}

private function connect() {
    connection = new NetConnection();
    connection.addEventListener(NetStatusEvent.NET_STATUS,
        netStatusHandler);
    connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
        securityErrorHandler);
    connection.connect(gateway);
}

function loadSomething():void {
    var responder:Responder = new Responder(onComplete, onFail);
    connection.call("myservice.something", responder, "");
}

function netStatusHandler(event:NetStatusEvent):void {
    trace("Unhandled net status event: " + event);
}
       
function securityErrorHandler(event:SecurityErrorEvent):void {
    trace("Security error: " + event);
}

// This function sometimes doesn't get called.
function onComplete(results) {
    something = results;
}

function onFail(results) {
    for each (var thisResult in results)
        trace(thisResult);
}
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: call() right after connect() really a good idea?

Jesse Warden-2
Your code looks correct, I blame Google.  For ultimate assurance:

1. put a trace in the fail; sometimes you get weird things back that can't be looped over
2. use Charles or a network monitor to watch the response; you WILL get a response back eventually, usually resulting in a timeout (which triggers an IOError), in NetConnection's case, a failed to connect for NetStatus or a fail.

On Thu, Nov 26, 2009 at 7:32 AM, Felix E. Klee <[hidden email]> wrote:
I have a PyAMF gateway running on Google App Engine. However, the SWF
that connects to it sometimes doesn't get a response. That happened
various times with Opera. And when I finally decided to investigate
the problem, I couldn't reproduce it.

So, just to make sure, is the code below - in the document class -
alright? In particular, I wonder whether it's a good idea to
immediately after "connection.connect()" call "connection.call()".

- Felix

The code:

private var connection:NetConnection;
private var something = 1;

// Constructor of document class.
public function SomeClass() {
   connect();
   loadSomething();
}

private function connect() {
   connection = new NetConnection();
   connection.addEventListener(NetStatusEvent.NET_STATUS,
       netStatusHandler);
   connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
       securityErrorHandler);
   connection.connect(gateway);
}

function loadSomething():void {
   var responder:Responder = new Responder(onComplete, onFail);
   connection.call("myservice.something", responder, "");
}

function netStatusHandler(event:NetStatusEvent):void {
   trace("Unhandled net status event: " + event);
}

function securityErrorHandler(event:SecurityErrorEvent):void {
   trace("Security error: " + event);
}

// This function sometimes doesn't get called.
function onComplete(results) {
   something = results;
}

function onFail(results) {
   for each (var thisResult in results)
       trace(thisResult);
}
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users


_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: call() right after connect() really a good idea?

Felix E. Klee
On Thu, Nov 26, 2009 at 5:59 PM, Jesse Warden <[hidden email]> wrote:
> Your code looks correct, I blame Google.

Thanks, Jesse, that's good to know.

> For ultimate assurance:
> 1. put a trace in the fail; sometimes you get weird things back that can't
> be looped over
> 2. use Charles or a network monitor to watch the response; you WILL get a
> response back eventually, usually resulting in a timeout (which triggers an
> IOError), in NetConnection's case, a failed to connect for NetStatus or a
> fail.

Well, I first need to reproduce the problem. Not that easy. And I need
a workaround in any case. So I consider repeating "connect.call()",
until a response is there, maybe every other second.
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: call() right after connect() really a good idea?

Jesse Warden-2
There's complex blog entries on this, but bottom line, all your calls can be "collected" into 1 call.  So, while you'll make 5 calls, and get 5 responses back, they may come all at once.  You'll see this if you use Charles or ServiceCapture; they'll come back on the same request.  While this is sometimes good, it can get confusing why all the latency.

On Thu, Nov 26, 2009 at 2:04 PM, Felix E. Klee <[hidden email]> wrote:
On Thu, Nov 26, 2009 at 5:59 PM, Jesse Warden <[hidden email]> wrote:
> Your code looks correct, I blame Google.

Thanks, Jesse, that's good to know.

> For ultimate assurance:
> 1. put a trace in the fail; sometimes you get weird things back that can't
> be looped over
> 2. use Charles or a network monitor to watch the response; you WILL get a
> response back eventually, usually resulting in a timeout (which triggers an
> IOError), in NetConnection's case, a failed to connect for NetStatus or a
> fail.

Well, I first need to reproduce the problem. Not that easy. And I need
a workaround in any case. So I consider repeating "connect.call()",
until a response is there, maybe every other second.
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users


_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: call() right after connect() really a good idea?

Felix E. Klee
On 11/26/09, Jesse Warden <[hidden email]> wrote:
> There's complex blog entries on this, but bottom line, all your calls can be
> "collected" into 1 call.  So, while you'll make 5 calls, and get 5 responses
> back, they may come all at once.  You'll see this if you use Charles or
> ServiceCapture; they'll come back on the same request.  While this is
> sometimes good, it can get confusing why all the latency.

Thanks for letting me know, Jesse. However, I don't see a problem
here. After all, there will be a point in time when the first call or
the first calls have failed. And the next call, then, will be
separate.

Didn't research the blog posts yet - am currently behind a really bad
Internet connection (EDGE in the middle of nowhere in deep Russian
province).

- Felix
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: call() right after connect() really a good idea?

Jesse Warden-2
Rad, sounds like an adventure!!!

My point was, you should NEVER lose calls; the only time Flash Player loses calls is your frame rate is really high and you have a lot of visuals happening.  At the very least, you should be getting failures.

On Thu, Nov 26, 2009 at 2:25 PM, Felix E. Klee <[hidden email]> wrote:
On 11/26/09, Jesse Warden <[hidden email]> wrote:
> There's complex blog entries on this, but bottom line, all your calls can be
> "collected" into 1 call.  So, while you'll make 5 calls, and get 5 responses
> back, they may come all at once.  You'll see this if you use Charles or
> ServiceCapture; they'll come back on the same request.  While this is
> sometimes good, it can get confusing why all the latency.

Thanks for letting me know, Jesse. However, I don't see a problem
here. After all, there will be a point in time when the first call or
the first calls have failed. And the next call, then, will be
separate.

Didn't research the blog posts yet - am currently behind a really bad
Internet connection (EDGE in the middle of nowhere in deep Russian
province).

- Felix
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users


_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users