| The Problem So far I have two projects:
I've setup the Flash code to call the Java objects to do things. I can set breakpoints on the java objects. I'm having lots of fun stepping through the java code I wrote. Eventually, my routine is ready to return its result. I click "Run -> Continue" to let the result return to Flash. Meanwhile, the Flash UI has already thrown a timeout fault. It took exception to waiting for me. There is a requestTimeout that can be configured in Flash to zero, which means no timeout: // When debugging, prevent timeout _remObj.requestTimeout = 0; Recompiled my front end, ran it, let it call java, I played in java, let the results return, and got this into my failure handler, exactly 30 seconds after the call: "error: NetConnection.Call.Failed: HTTP: Failed" Great, I get 30 seconds to finish debugging the call, or it times out. So this is not just debugging. It's more like safecracking.... Here's the documentation for that field: "mx.rpc.AbstractService.requestTimeout(value:int):void Do you think Mozart had to spend time debugging his piano? Maybe that's a thought more tools developers should have in mind.... |
Turns out there were some bugs in this area of timeouts with remoting from Flex and especially Air applications. I am using a late enough SDK that I should not have been encountering them. I suspect the "value less than or equal to zero" documentation is wrong, perhaps because it hasn't been updated.
This bug shows the proper order for setting up the remote object. Notice the use of 240 seconds, instead of just setting to 0.
http://bugs.adobe.com/jira/browse/SDK-30426
// RemoteObject times out after 30 seconds every time // Created: 05/10/11 02:55 PM Updated: 05/27/11 11:39 AM Resolved: 05/27/11 11:38 AM // Found in Version: Flex SDK 4.5 (Release) - 4.5.0.20967 remoteObject = new RemoteObject( serviceName ); remoteObject.requestTimeout = 240; // 4 minute request timeout remoteObject.channelSet = new ChannelSet(); var amfChannel:AMFChannel = new AMFChannel( "my-amf", applicationModel.environment.endpoint ); amfChannel.netConnection.httpIdleTimeout = remoteObject.requestTimeout * 1000; remoteObject.channelSet.addChannel( amfChannel );
Using this technique, I was able to sit around in Eclipse debugger looking at my remote object's java code for at least 2 minutes. I will now explore a longer timeout when debugging.
Other related bugs and documentation:
- Category of issues: Bugs related to Flex SDK : RPC : RemoteObject - http://bugs.adobe.com/jira/browse/SDK/component/10352
- Closed - http://bugs.adobe.com/jira/browse/SDK-27551 - [AIR 2697003] Ensure that requestTimeout properties on any relevant messaging classes set NetConnection.idleTimeout (AIR only)
- Summary of Flex SDK AIR application request timeouts (from "Ensure that requestTimeout properties on any relevant messaging classes set URLRequest.idleTimeout (AIR only)" https://bugs.adobe.com/jira/browse/SDK-22016)
- Closed - https://bugs.adobe.com/jira/browse/SDK-15403 - requestTimeout of HTTPService has no effect while running an an AIR application.
- http://old.nabble.com/RemoteObject---request-timeout-td9105761.html
- Advice: when you make a call that modifies, creates or deletes data on the server and the request times out you should query the server for its current state before attempting to retry the call.
Some people possibly still encountering issues (May 2011):
- http://forums.adobe.com/thread/100543 - RemoteObject request timeout
Possibly Related issues:
- Keeping a http session alive http session as long user has open the flex app in the browser? - http://stackoverflow.com/questions/1649664/best-practice-keep-alive-session-in-flex
- There is no standard way of doing this. We do a ping-pong with the server every n-seconds (check the AS3 Timer class), where n must be lower than the session timeout. It's best to keep your session timeout as low as possible to reduce memory consumption on the server, especially when you have a lot of concurrent users.
- How to handle server timeout in BlazeDS - http://stackoverflow.com/questions/281627/graceful-handling-of-server-timeout-in-blazeds
- Flex BlazeDS Java session handling timeouts, sessions invalidated after 30 minutes - http://forums.adobe.com/thread/839400?tstart=-2
Eclipse debugging:
- Challenges with remote debugging - http://forums.dzone.com/eclipse/955-pulling-out-hair-remote-debugging.html
- Timeouts while remote debugging - http://www.myeclipseide.com/PNphpBB2-viewtopic-t-24612.html
- Configuring eclipse for remote debugging - http://oreilly.com/java/archive/eclipse-jboss-remote-debug.html
References:
- Cool list of Adobe Flex With Java articles - http://www.brightworks.com/technology/adobe_flex/with_java.html
- Java EE and Flex - Can We Talk - http://www.javaworld.com/javaworld/jw-02-2009/jw-02-javaee-flex-2.html?page=5
- Setting up a Basic BlazeDS Server with debugging - http://flexbandit.com/archives/55
- Remote debugging using Flex Builder IDE - http://blogs.4point.com/armaghan.chaudhary/2009/04/remote-debugging-using-flex-builder-ide.html