title: How can I catch and/or deal with "Error #2030: End of file was encountered" on a NetConnection in ActionScript 3?
body: <p>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:</p>
  
  <pre><code>"Error: Error #2030: End of file was encountered."
  </code></pre>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>public class MyClient extends Sprite
  {
     public function FOWClient()
     {
        loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
     }
  
     private function uncaughtErrorHandler(event:UncaughtErrorEvent):void
     {
        trace("UNCAUGHT EXCEPTION!!!");
     }        
  }
  </code></pre>
  
  <p>My uncaught exception handler will get called properly if I purposely throw in some errors, but it never gets called when this <code>Error #2030</code> happens.</p>
  
  <p>So there are really two outcomes that would be acceptable to me:</p>
  
  <ol>
  <li>How the heck can I catch this "End of file was encountered" error and deal with it in code?</li>
  <li>If I can't catch it, are there any thoughts on what's causing it and how I fix that?</li>
  </ol>
  
  <p>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 &amp; video, I don't see the issue.  Unfortunately, I don't yet have any good ideas beyond that.</p>
  
  <p>Any help is appreciated.  Thanks!</p>