How can I catch and/or deal with "Error #2030: End of file was encountered" on a NetConnection in ActionScript 3?

Brent Writes Code picture Brent Writes Code · Mar 31, 2011 · Viewed 9.4k times · Source

I'm currently writing a client in ActionScript 3 that talks to a Red5 application/media server via a NetConnection object. The server sends the client multiple types of data over this connection including video, audio and remote procedure calls. After an indeterminate amount of time (sometimes 10 seconds, sometimes 10 minutes) I see the following error in a popup window from my Debug version of the Flash client:

"Error: Error #2030: End of file was encountered."

I'm in the process of trying to figure out what's causing this error and the thing that's really driving me nuts is that I can't seem to catch it. I realize that the error probably indicates some low-level network read failing, but the fact that it generates a popup window in the debug flash player implies that I should be able to catch it.

Since the error has no associated stack trace, I went so far as to add the an uncaught exception handler on my base Sprite object:

public class MyClient extends Sprite
{
   public function FOWClient()
   {
      loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
   }

   private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
   {
      trace("UNCAUGHT EXCEPTION!!!");
   }        
}

My uncaught exception handler will get called properly if I purposely throw in some errors, but it never gets called when this Error #2030 happens.

So there are really two outcomes that would be acceptable to me:

  1. How the heck can I catch this "End of file was encountered" error and deal with it in code?
  2. If I can't catch it, are there any thoughts on what's causing it and how I fix that?

I'm pretty sure I've narrowed it down to having to do with RPC calls being made from my server to my client because when I disable those, but leave audio & video, I don't see the issue. Unfortunately, I don't yet have any good ideas beyond that.

Any help is appreciated. Thanks!

Answer

jbalsas picture jbalsas · Mar 31, 2011

Some of this errors are thrown if the proper listener is not added.

Are you listening for asyncError and ioError events from your netconnection?

If not, just give it a try.