Exemplo n.º 1
0
        private void _pusher_ConnectionStateChanged(object sender, ConnectionState state)
        {
            _loggingService.WriteInformation($"Pusher is {state}");

            try
            {
                if (state == ConnectionState.WaitingToReconnect)
                {
                    _connectionAttempts++;

                    if (_connectionAttempts >= 5)
                    {
                        _connectionAttempts = 0;
                        ConnectionFailedEvent?.Invoke();
                    }
                }
                else if (state == ConnectionState.Connected)
                {
                    _connectionAttempts = 0;
                }
            }
            catch (Exception e)
            {
                _loggingService.WriteInformation($"Error handling the pusher '{state}' state. {e}");
            }
        }
Exemplo n.º 2
0
        public async Task WhenKeyUnknown_ThenErrorIsShownAndWindowIsClosed(
            [LinuxInstance] ResourceTask <InstanceLocator> instanceLocatorTask)
        {
            var instanceLocator = await instanceLocatorTask;

            using (var key = new RsaSshKey(new RSACng()))
            {
                ConnectionFailedEvent deliveredEvent = null;
                this.eventService.BindHandler <ConnectionFailedEvent>(e => deliveredEvent = e);

                var broker = new SshTerminalConnectionBroker(
                    this.serviceProvider);
                await broker.ConnectAsync(
                    instanceLocator,
                    new IPEndPoint(await PublicAddressFromLocator(instanceLocator), 22),
                    AuthorizedKey.ForMetadata(key, "test", true, null))
                .ConfigureAwait(true);

                Assert.IsNotNull(deliveredEvent, "Event fired");
                Assert.IsInstanceOf(typeof(SshNativeException), this.ExceptionShown);
                Assert.AreEqual(
                    LIBSSH2_ERROR.AUTHENTICATION_FAILED,
                    ((SshNativeException)this.ExceptionShown).ErrorCode);
            }
        }
Exemplo n.º 3
0
        public async Task WhenWrongPort_ThenErrorIsShownAndWindowIsClosed()
        {
            using (var key = new RsaSshKey(new RSACng()))
            {
                ConnectionFailedEvent deliveredEvent = null;
                this.eventService.BindHandler <ConnectionFailedEvent>(e => deliveredEvent = e);

                var broker = new SshTerminalConnectionBroker(
                    this.serviceProvider);
                await broker.ConnectAsync(
                    new InstanceLocator("project-1", "zone-1", "instance-1"),
                    NonSshEndpoint,
                    AuthorizedKey.ForMetadata(key, "test", true, null))
                .ConfigureAwait(true);

                Assert.IsNotNull(deliveredEvent, "Event fired");
                Assert.IsInstanceOf(typeof(SocketException), this.ExceptionShown);
                Assert.AreEqual(
                    SocketError.ConnectionRefused,
                    ((SocketException)this.ExceptionShown).SocketErrorCode);
            }
        }
Exemplo n.º 4
0
 // Connections
 public override void ConnectionFailed(ConnectionFailedEvent @event)
 {
     Log(LogLevel.Error, "{0}: failed. Exception: {1}", Label(@event.ConnectionId), @event.Exception);
 }
Exemplo n.º 5
0
 public static void InvokeConnectionFailedEvent(ConnectionFailedEventArgs args)
 {
     ConnectionFailedEvent?.Invoke(args);
 }
Exemplo n.º 6
0
 private void Handle(ConnectionFailedEvent @event)
 {
     Error(TraceSourceEventHelper.ConnectionIdBase + 5, @event.Exception, "{0}: failed.", TraceSourceEventHelper.Label(@event.ConnectionId));
 }
 public void ConnectionFailed(ConnectionFailedEvent @event)
 {
 }