Пример #1
0
        private void OnSocketError(IClient c, ClientErrorArgs e)
        {
            HttpApiServer httpApiServer = Server.Gateway.HttpServer;

            if (httpApiServer.EnableLog(BeetleX.EventArgs.LogType.Error))
            {
                httpApiServer.Log(BeetleX.EventArgs.LogType.Error, $"gateway request {Server.Host}:{Server.Port} error {e.Message}@{e.Error.InnerException?.Message} status {Status}");
            }

            if (Status == RequestStatus.Requesting)
            {
                EventResponseErrorArgs erea;
                if (e.Error is SocketException)
                {
                    Code = Gateway.SERVER_SOCKET_ERROR;
                    erea = new EventResponseErrorArgs(Request, Response, UrlRoute.Gateway, e.Error.Message, Gateway.SERVER_SOCKET_ERROR);
                }
                else
                {
                    Code = Gateway.SERVER_PROCESS_ERROR_CODE;
                    erea = new EventResponseErrorArgs(Request, Response, UrlRoute.Gateway, e.Error.Message, Gateway.SERVER_PROCESS_ERROR_CODE);
                }
                OnCompleted(erea);
            }
            else
            {
                Code = Gateway.SERVER_OTHRER_ERROR_CODE;
                if (Status > RequestStatus.None)
                {
                    OnCompleted(null);
                }
            }
        }
Пример #2
0
 private void OnError(IClient client, ClientErrorArgs e)
 {
     try
     {
         NetError.Invoke(client, e);
     }
     catch
     {
     }
 }
Пример #3
0
        /// <summary>
        /// 记录异常错误
        /// </summary>
        /// <param name="Error"></param>
        public void ExecuteRecordLog(ClientErrorArgs Error)
        {
            String ExceptionInfomations = $"Service errored with exception:【{Error.Message}】====write time:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}\n";
            var    Diretories           = Path.Combine(AppContext.BaseDirectory, "SocketError");

            if (!Directory.Exists(Diretories))
            {
                Directory.CreateDirectory(Diretories);
            }
            File.AppendAllText(Path.Combine(Diretories, "SocketErrorInfo.log"), ExceptionInfomations);
            Console.WriteLine(ExceptionInfomations);
        }
Пример #4
0
 private void OnError(IClient c, ClientErrorArgs e)
 {
     if (e.Error is BeetleX.BXException || e.Error is System.Net.Sockets.SocketException ||
         e.Error is System.ObjectDisposedException)
     {
         c.DisConnect();
         OnCompleted(ResultType.NetError, e.Error.Message);
     }
     else
     {
         OnCompleted(ResultType.DataError, e.Error.Message);
     }
 }
Пример #5
0
        private void MinerServer_OnClientError(object sender, ClientErrorArgs e)
        {
            Miner miner = _minerManager.GetMiner(e.connection);

            if (miner != null)
            {
                Log.Information("{0} has disconnected for {1}", miner.workerIdentifier, _poolClient.poolEndPoint);
                _minerManager.RemoveMiner(miner);
            }
            else
            {
                Log.Information("{0} has disconnected for {1}", e.connection.endPoint, _poolClient.poolEndPoint);
            }

            _poolClient.IsPoolConnectionRequired();
        }
Пример #6
0
        void EventClientError(IClient c, ClientErrorArgs e)
        {
            if (CurrentTask == null)
            {
                RecordLog(LogLevel.Error, $"[NoMessage]{e.Message}\n{e.Error}");
                return;
            }
            var task = CurrentTask;

            RecordLog(LogLevel.Error, $"[{task.Message.ID}]{e.Message}\n{e.Error}");
            task.Message.State = MessageState.NetworkError;
            task.Result.State  = MessageState.NetworkError;
            var wait = task.WaitingTask;

            if (wait != null)
            {
                wait.TrySetResult(task.Result);
            }
        }
Пример #7
0
        private void OnClientError(IClient c, ClientErrorArgs e)
        {
            if (OnWSConnected)
            {
                if (e.Error is BXException)
                {
                    OnWSConnected = false;
                }
                lock (mLockReceive)
                {
                    if (mReceiveCompletionSource != null)
                    {
                        var completed = mReceiveCompletionSource;
                        mReceiveCompletionSource = null;
                        Task.Run(() =>
                        {
                            completed.Error(e.Error);
                        });
                        return;
                    }
                }

                if (DataReceive != null)
                {
                    try
                    {
                        WSReceiveArgs wse = new WSReceiveArgs();
                        wse.Client = this;
                        wse.Error  = e.Error;
                        DataReceive?.Invoke(this, wse);
                    }
                    catch { }
                }
            }
            else
            {
                OnConnectResponse(e.Error, null);
            }
        }
Пример #8
0
 private void OnClientError(IClient c, ClientErrorArgs e)
 {
     if (OnWSConnected)
     {
         if (e.Error is BXException)
         {
             OnWSConnected = false;
         }
         try
         {
             WSReceiveArgs wse = new WSReceiveArgs();
             wse.Client = this;
             wse.Error  = e.Error;
             DataReceive?.Invoke(this, wse);
         }
         catch { }
     }
     else
     {
         OnConnectResponse(e.Error, null);
     }
 }
Пример #9
0
 private void OnSocketError(IClient c, ClientErrorArgs e)
 {
     Error = e.Error.Message;
     if (Status == RequestStatus.Requesting)
     {
         if (e.Error is SocketException)
         {
             Code = RECEIVE_SOCKET_ERROR;
         }
         else
         {
             Code = RECEIVE_PROCESS_ERROR;
         }
         OnCompleted();
     }
     else
     {
         Code = RECEIVE_DATA_ERROR;
         if (Status > RequestStatus.None)
         {
             OnCompleted();
         }
     }
 }
Пример #10
0
 private void onEventClientError(IClient c, ClientErrorArgs e)
 {
     requestResult.TrySetException(e.Error);
 }
Пример #11
0
        // Dunno if sender should really be null for the event invocations, but I can't use this 'cause static class, so....

        internal static void InvokeClientError(ClientErrorArgs args)
        {
            ClientError?.Invoke(null, args);
        }