/// <summary>
        /// Receives the version of the client from the version service by a given config
        /// </summary>
        private void ReceiveVersionWithConfig(MonitoredClient client)
        {
            if (!client.Config.CheckVersion)
            {
                // Don't do any version check.
                HandleConnectionState(client, InternalConnectionState.VersionMatch);
            }
            else
            {
                Logger.Log(LogLevel.Debug, "Trying to get version info for service '{0}'", client.ServiceName);

                // Get all endpoints for this service
                var endpoints = VersionService.ServiceEndpoints(client.ServiceName);
                if (endpoints == null)
                {
                    HandleConnectionFailure(client, "Endpoint service not available");
                    return;
                }

                // Select endpoint by path for config
                var endpoint = endpoints.FirstOrDefault(e => e.Path == client.Config.Endpoint);
                if (endpoint == null)
                {
                    HandleConnectionFailure(client, "Endpoint not found on server");
                    return;
                }

                // Finally reached the server
                Logger.Log(LogLevel.Debug, "Got version '{0}' for service '{1}'", endpoint.Version, client.ServiceName);
                var clientVersion = Version.Parse(client.Config.ClientVersion);
                var serverVersion = Version.Parse(endpoint.Version);
                client.ClientInfo.ServerVersion = endpoint.Version;

                // Compare version
                if (endpoint.Binding == client.Config.BindingType && VersionCompare.ClientMatch(serverVersion, clientVersion))
                {
                    HandleConnectionState(client, InternalConnectionState.VersionMatch);
                }
                else
                {
                    HandleConnectionState(client, InternalConnectionState.VersionMissmatch);
                }
            }
        }
        /// <summary>
        /// Receives the version without a given configuration. The configuration will be loaded from
        /// the version service
        /// </summary>
        private void ReceiveVersionWithoutConfig(MonitoredClient client)
        {
            Logger.Log(LogLevel.Debug, "Trying to get service configuration for service '{0}'", client.ServiceName);

            // Get all endpoints for this service
            var endpoints = VersionService.ServiceEndpoints(client.ServiceName);

            if (endpoints == null || endpoints.Length == 0)
            {
                HandleConnectionFailure(client, "Endpoint service or endpoint not available");
                return;
            }

            // Select endpoint by matching version
            var clientVersion = Version.Parse(client.ClientInfo.ClientVersion);
            var endpoint      = endpoints
                                .Where(e =>
            {
                var serverVersion = Version.Parse(e.Version);
                // The client factory can not connect WebHttp
                return(e.Binding > ServiceBindingType.WebHttp && VersionCompare.ClientMatch(serverVersion, clientVersion));
            }).OrderByDescending(e => e.Version).FirstOrDefault();

            if (endpoint == null)
            {
                HandleConnectionState(client, InternalConnectionState.VersionMissmatch);
                return;
            }

            // Finally reached the server
            client.Endpoint = endpoint;
            Logger.Log(LogLevel.Debug, "Got service configuration for service '{0}'", client.ServiceName);
            client.ClientInfo.ServerVersion = client.Endpoint.Version;
            client.ClientInfo.Uri           = endpoint.Address;

            HandleConnectionState(client, InternalConnectionState.VersionMatch);
        }