       getChannel.readBytes(bytes, offset, length);
     }
 
-    private function onError(e:ErrorEvent):void {
-      trace("HTTPClient socket error");
-    }
-
     public function disconnect():void {
       if (getChannel.connected) {
         getChannel.close();
+
+        getChannel.removeEventListener(Event.CONNECT, onGetChannelConnect);
+        getChannel.removeEventListener(ProgressEvent.SOCKET_DATA, onGetChannelData);
+        getChannel.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
+        getChannel.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
       }
       if (postChannel.connected) {
         postChannel.close();
+
+        postChannel.removeEventListener(Event.CONNECT, onPostChannelConnect);
+        postChannel.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
+        postChannel.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
       }
 
       /* should probably wait for close, but it doesn't seem to fire properly */


      dispatchEvent(new Event('connected'));
    }
  }
}

      getChannel.timeout = 5000;
      getChannel.addEventListener(Event.CONNECT, onGetChannelConnect);
      getChannel.addEventListener(ProgressEvent.SOCKET_DATA, onGetChannelData);
      getChannel.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
      getChannel.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

      postChannel = new Socket();
      postChannel.timeout = 5000;
      postChannel.addEventListener(Event.CONNECT, onPostChannelConnect);
      postChannel.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
      postChannel.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);

      getChannelData = new ByteArray();
      postChannelData = new ByteArray();
