protected void Open(TcpClient tcpClient) { int elapseConnectTime = 1; Random rand = new Random(); _ServerBusy = false; while (elapseConnectTime < this.ConnectionTimeout * 1000) { tcpClient.Connect(this.ConnectionTimeout * 1000); try { tcpClient.SendSyncMessage((short)ConnectEvent.Connect, BuildConnectionMessage()); break; } catch (Exception e) { if (e.Message.Trim() == "Too many connects on server") { tcpClient.Close(); _Connected = false; ConnectionString = ConnectionString; if (!CommandReportNoCache && TryConnectTimeout > 0) { if (elapseConnectTime >= TryConnectTimeout) { _ServerBusy = true; return; } } int sleepMillisecond = rand.Next(200, 800); elapseConnectTime += sleepMillisecond; System.Threading.Thread.Sleep(sleepMillisecond); continue; } tcpClient.Close(); throw e; } } if (elapseConnectTime > this.ConnectionTimeout * 1000) { throw new System.Data.DataException("Connect timeout.The hubbledotnet server is too busy right now."); } _Connected = true; _State = System.Data.ConnectionState.Open; DataCacheMgr.OnConnect(this); }