private void OnError(object sender, EventSource.ExceptionEventArgs e)
        {
            var ex = e.Exception;

            LogHelpers.LogException(_log, "Encountered EventSource error", ex);
            var recoverable = true;

            if (ex is EventSource.EventSourceServiceUnsuccessfulResponseException respEx)
            {
                int status = respEx.StatusCode;
                _log.Error(HttpErrors.ErrorMessage(status, "streaming connection", "will retry"));
                RecordStreamInit(true);
                if (!HttpErrors.IsRecoverable(status))
                {
                    recoverable = false;
                    _initTask.TrySetException(ex); // sends this exception to the client if we haven't already started up
                    ((IDisposable)this).Dispose();
                }
            }

            var errorInfo = ex is EventSource.EventSourceServiceUnsuccessfulResponseException re ?
                            DataSourceStatus.ErrorInfo.FromHttpError(re.StatusCode) :
                            DataSourceStatus.ErrorInfo.FromException(ex);

            _dataSourceUpdates.UpdateStatus(recoverable ? DataSourceState.Interrupted : DataSourceState.Off,
                                            errorInfo);
        }
예제 #2
0
 private void OnError(object sender, EventSource.ExceptionEventArgs e)
 {
     Log.ErrorFormat("Encountered EventSource error: {0}",
                     e.Exception,
                     Util.ExceptionMessage(e.Exception));
     if (e.Exception is EventSource.EventSourceServiceUnsuccessfulResponseException)
     {
         if (((EventSource.EventSourceServiceUnsuccessfulResponseException)e.Exception).StatusCode == 401)
         {
             Log.Error("Received 401 error, no further streaming connection will be made since SDK key is invalid");
             ((IDisposable)this).Dispose();
         }
     }
 }
예제 #3
0
 private void OnError(object sender, EventSource.ExceptionEventArgs e)
 {
     Log.ErrorFormat("Encountered EventSource error: {0}",
                     e.Exception,
                     Util.ExceptionMessage(e.Exception));
     if (e.Exception is EventSource.EventSourceServiceUnsuccessfulResponseException)
     {
         int status = ((EventSource.EventSourceServiceUnsuccessfulResponseException)e.Exception).StatusCode;
         Log.Error(Util.HttpErrorMessage(status, "streaming connection", "will retry"));
         if (!Util.IsHttpErrorRecoverable(status))
         {
             _initTask.TrySetException(e.Exception); // sends this exception to the client if we haven't already started up
             ((IDisposable)this).Dispose();
         }
     }
 }
예제 #4
0
        private void OnError(object sender, EventSource.ExceptionEventArgs e)
        {
            var ex          = e.Exception;
            var recoverable = true;

            DataSourceStatus.ErrorInfo errorInfo;

            RecordStreamInit(true);

            if (ex is EventSourceServiceUnsuccessfulResponseException respEx)
            {
                int status = respEx.StatusCode;
                errorInfo = DataSourceStatus.ErrorInfo.FromHttpError(status);
                if (!HttpErrors.IsRecoverable(status))
                {
                    recoverable = false;
                    _log.Error(HttpErrors.ErrorMessage(status, "streaming connection", ""));
                }
                else
                {
                    _log.Warn(HttpErrors.ErrorMessage(status, "streaming connection", "will retry"));
                }
            }
            else
            {
                errorInfo = DataSourceStatus.ErrorInfo.FromException(ex);
                _log.Warn("Encountered EventSource error: {0}", LogValues.ExceptionSummary(ex));
                _log.Debug(LogValues.ExceptionTrace(ex));
            }

            _updateSink.UpdateStatus(recoverable ? DataSourceState.Interrupted : DataSourceState.Shutdown,
                                     errorInfo);

            if (!recoverable)
            {
                // Make _initTask complete to tell the client to stop waiting for initialization. We use
                // TrySetResult rather than SetResult here because it might have already been completed
                // (if for instance the stream started successfully, then restarted and got a 401).
                _initTask.TrySetResult(false);
                ((IDisposable)this).Dispose();
            }
        }
예제 #5
0
 private void OnError(object sender, EventSource.ExceptionEventArgs e)
 {
     Log.ErrorFormat("Encountered EventSource error: {0}",
                     e.Exception,
                     Util.ExceptionMessage(e.Exception));
     if (e.Exception is EventSource.EventSourceServiceUnsuccessfulResponseException)
     {
         int status = ((EventSource.EventSourceServiceUnsuccessfulResponseException)e.Exception).StatusCode;
         Log.Error(Util.HttpErrorMessage(status, "streaming connection", "will retry"));
         if (!Util.IsHttpErrorRecoverable(status))
         {
             try
             {
                 // if client is initializing, make it stop waiting
                 _initTask.SetResult(true);
             }
             catch (InvalidOperationException)
             {
                 // the task was already set - nothing more to do
             }
             ((IDisposable)this).Dispose();
         }
     }
 }