Exemple #1
0
        private void ReconnectTo(NodeEndPoints endPoints)
        {
            IPEndPoint endPoint = _settings.UseSslConnection
                                          ? endPoints.SecureTcpEndPoint ?? endPoints.TcpEndPoint
                                          : endPoints.TcpEndPoint;

            if (endPoint == null)
            {
                CloseConnection("No end point is specified while trying to reconnect.");
                return;
            }

            if (_state != ConnectionState.Connected || _connection.RemoteEndPoint.Equals(endPoint))
            {
                return;
            }

            var msg = string.Format("EventStoreConnection '{0}': going to reconnect to [{1}]. Current endpoint: [{2}, L{3}].",
                                    _esConnection.ConnectionName, endPoint, _connection.RemoteEndPoint, _connection.LocalEndPoint);

            if (_settings.VerboseLogging)
            {
                _settings.Log.Info(msg);
            }
            CloseTcpConnection(msg);

            _state           = ConnectionState.Connecting;
            _connectingPhase = ConnectingPhase.EndPointDiscovery;
            EstablishTcpConnection(endPoints);
        }
Exemple #2
0
        private void EstablishTcpConnection(NodeEndPoints endPoints)
        {
            var endPoint = _settings.UseSslConnection ? endPoints.SecureTcpEndPoint ?? endPoints.TcpEndPoint : endPoints.TcpEndPoint;

            if (endPoint == null)
            {
                CloseConnection("No end point to node specified.");
                return;
            }

            LogDebug("EstablishTcpConnection to [{0}]", endPoint);

            if (_state != ConnectionState.Connecting)
            {
                return;
            }
            if (_connectingPhase != ConnectingPhase.EndPointDiscovery)
            {
                return;
            }

            _connectingPhase = ConnectingPhase.ConnectionEstablishing;
            _connection      = new TcpPackageConnection(
                _settings.Log,
                endPoint,
                Guid.NewGuid(),
                _settings.UseSslConnection,
                _settings.TargetHost,
                _settings.ValidateServer,
                _settings.ClientConnectionTimeout,
                (connection, package) => EnqueueMessage(new HandleTcpPackageMessage(connection, package)),
                (connection, exc) => EnqueueMessage(new TcpConnectionErrorMessage(connection, exc)),
                connection => EnqueueMessage(new TcpConnectionEstablishedMessage(connection)),
                (connection, error) => EnqueueMessage(new TcpConnectionClosedMessage(connection, error)));
            _connection.StartReceiving();
        }
        private void ReconnectTo(NodeEndPoints endPoints)
        {
            IPEndPoint endPoint = _settings.UseSslConnection
                                          ? endPoints.SecureTcpEndPoint ?? endPoints.TcpEndPoint
                                          : endPoints.TcpEndPoint;
            if (endPoint == null)
            {
                CloseConnection("No end point is specified while trying to reconnect.");
                return;
            }

            if (_state != ConnectionState.Connected || _connection.RemoteEndPoint.Equals(endPoint))
                return;

            var msg = string.Format("EventStoreConnection '{0}': going to reconnect to [{1}]. Current endpoint: [{2}, L{3}].",
                                    _esConnection.ConnectionName, endPoint, _connection.RemoteEndPoint, _connection.LocalEndPoint);
            if (_settings.VerboseLogging) _settings.Log.Info(msg);
            CloseTcpConnection(msg);

            _state = ConnectionState.Connecting;
            _connectingPhase = ConnectingPhase.EndPointDiscovery;
            EstablishTcpConnection(endPoints);
        }
        private void EstablishTcpConnection(NodeEndPoints endPoints)
        {
            var endPoint = _settings.UseSslConnection ? endPoints.SecureTcpEndPoint ?? endPoints.TcpEndPoint : endPoints.TcpEndPoint;
            if (endPoint == null)
            {
                CloseConnection("No end point to node specified.");
                return;
            }

            LogDebug("EstablishTcpConnection to [{0}]", endPoint);

            if (_state != ConnectionState.Connecting) return;
            if (_connectingPhase != ConnectingPhase.EndPointDiscovery) return;

            _connectingPhase = ConnectingPhase.ConnectionEstablishing;
            _connection = new TcpPackageConnection(
                    _settings.Log,
                    endPoint,
                    Guid.NewGuid(),
                    _settings.UseSslConnection,
                    _settings.TargetHost,
                    _settings.ValidateServer,
                    _settings.ClientConnectionTimeout,
                    (connection, package) => EnqueueMessage(new HandleTcpPackageMessage(connection, package)),
                    (connection, exc) => EnqueueMessage(new TcpConnectionErrorMessage(connection, exc)),
                    connection => EnqueueMessage(new TcpConnectionEstablishedMessage(connection)),
                    (connection, error) => EnqueueMessage(new TcpConnectionClosedMessage(connection, error)));
            _connection.StartReceiving();
        }
Exemple #5
0
 public EstablishTcpConnectionMessage(NodeEndPoints endPoints)
 {
     EndPoints = endPoints;
 }
Exemple #6
0
 public EstablishTcpConnectionMessage(NodeEndPoints endPoints)
 {
     EndPoints = endPoints;
 }