 			
 			_socket.writeUTFBytes(headers.join('\r\n'));
 			_socket.flush();
+			
+			_openingHandshakeTimeout = setTimeout(closeConnection, 20000);
 		}
 		
 		private function readHttpHeader(buffer:ByteArray):String {

			headers.push('Connection: Upgrade');
			headers.push('Host: ' + _hostport);
			headers.push('Origin: ' + _origin);
			if (_cookie) {
				headers.push('Cookie: ' + _cookie);
			}
			if (_protocols) {
				headers.push('Sec-WebSocket-Protocol: ' + _protocols.join(", "));
			}
			headers.push('Sec-WebSocket-Key: ' + key);

		private var _expectedChallengeResponse:String;
		private var _fragment:WebSocketFrame;
		private var _emptyBufferTimeout:int;
		private var _openingHandshakeTimeout:int;
		private var _closingHandshakeTimeout:int;
		
		private var _secure:Boolean;
