Code Monkey home page Code Monkey logo

discovery's Introduction

.NET Service Discovery & Registration

NOTICE: This repository has been relocated as a sub-directory under the Steeltoe repository. All issues and future development will be done under that repository.

A Service Registry provides a database which applications can use in implementing the Service Discovery pattern; one of the key tenets of a micro-service based architecture. Trying to hand-configure each client of a service or adopt some form of access convention can be difficult and prove to be brittle in production. Instead, your applications can use a Service Registry to dynamically discover and call registered services.

There are several popular options for Service Registries. Netflix built and then open-sourced their own service registry, Eureka. Another relatively new, but increasingly popular option is Consul.

This repository contains various packages for interacting with Service Registries.

Windows Master: AppVeyor Master

Windows Dev: AppVeyor Dev

Linux/OS X Master: Travis Master

Linux/OSX Dev: Travis Dev

.NET Runtime & Framework Support

The packages are intended to support both .NET 4.6.1+ and .NET Core (CoreCLR/CoreFX) run-times. They are built and unit tested on Windows, Linux and OSX.

While the primary usage of the providers is intended to be with ASP.NET Core applications, they should also work fine with UWP, Console and ASP.NET 4.x apps.

Currently all of the code and samples have been tested on .NET Core 2.0, .NET 4.6.x, and on ASP.NET Core 2.0.0.

Usage

For more information on how to use these components see the online Steeltoe documentation.

Nuget Feeds

All new development is done on the dev branch. More stable versions of the packages can be found on the master branch. The latest prebuilt packages from each branch can be found on one of two MyGet feeds. Released version can be found on nuget.org.

Building Pre-requisites

To build and run the unit tests:

  1. .NET Core SDK 2.0.3 or greater
  2. .NET Core Runtime 2.0.3

Building Packages & Running Tests - Windows

To build the packages on windows:

  1. git clone ...
  2. cd clone directory
  3. cd src/project (e.g. cd src/Steeltoe.Discovery.EurekaBase)
  4. dotnet restore
  5. dotnet pack --configuration Release or Debug

The resulting artifacts can be found in the bin folder under the corresponding project. (e.g. src/Steeltoe.Discovery.EurekaBase/bin

To run the unit tests:

  1. git clone ...
  2. cd clone directory
  3. cd test/test project (e.g. cd test/Steeltoe.Discovery.ClientCore.Test)
  4. dotnet restore
  5. dotnet xunit -verbose

Building Packages & Running Tests - Linux/OSX

To build the packages on Linux/OSX:

  1. git clone ...
  2. cd clone directory
  3. cd src/project (e.g.. cd src/Steeltoe.Discovery.ClientCore)
  4. dotnet restore
  5. dotnet pack --configuration Release or Debug

The resulting artifacts can be found in the bin folder under the corresponding project. (e.g. src/Steeltoe.Discovery.ClientCore/bin

To run the unit tests:

  1. git clone ...
  2. cd clone directory
  3. cd test/test project (e.g. cd test/Steeltoe.Discovery.ClientCore.Test)
  4. dotnet restore test
  5. dotnet xunit -verbose -framework netcoreapp2.0

Sample Applications

See the Samples repository for examples of how to use these packages.

discovery's People

Contributors

anvar-ramazanov avatar dgodd avatar diablo39 avatar dtillman avatar hananiel avatar jkonicki avatar kimbell avatar macsux avatar majian159 avatar mavenraven avatar qazuc88 avatar timhess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discovery's Issues

Can we set the instanceId to the current IP address and port.

Hello,

Can we set the instanceId to the current IP address and port without specify the instanceId in appsettings.json?

For example, a product service has two instance, and their IP address and port are 10.0.10.1:9000 and 10.0.10.2:9001.

I want to set the instanceIds of them are 10.0.10.1:9000 and 10.0.10.2:9001 automatically.

Java client can do this by the following configuration

eureka:
  instance:
    prefer-ip-address: true
    instance-id: ${spring.cloud.client.ip-address}:${server.port}
  client:
    serviceUrl:
      defaultZone: http://10.0.10.100/eureka

I take a look on the code, when we not specify the instanceId, it will set the instanceId like the following format.

options.InstanceId = options.GetHostName(false) + ":" + options.AppName + ":" + options.NonSecurePort;

Maybe we can set a format string to the instanceId ?

So that we can make it more flexible.

Service Registry URL not resolved in PCF Marketplace Service

Hi I have created some sample Service Registry and Discovery applications. This is working fine in Local machine where I installed Eureka server to Register and Discover the services. When I push the same into PCF and bind Service Registry Market Place services to my applications, it's unable to use the Service Registry. It still uses the serviceUrl as http://localhost:8761/eureka/ and not taking the bounded services from VcapServices and throwing an exception while registering and discovering the services. My sample source code can be found here https://github.com/SivakumarShan/steeltoeservicediscovery
Looking for the help to use PCF Service Registry.

Thanks,
Siva

Does eureka:client:serviceUrl support HA enabled eureka cluster config?

Currently, I use config:

"eureka": {
    "client": {
      "serviceUrl": "http://server1:8761/eureka/",
      "shouldFetchRegistry": false,
      "validate_certificates": false
    },

it works. but I have two HA enabled eureka servers : server1, server2, but following config NOT work:

"eureka": {
    "client": {
      "serviceUrl": "http://server1:8761/eureka/,http://server2:8761/eureka/",
      "shouldFetchRegistry": false,
      "validate_certificates": false
    },

any ideas?

Logging template gives weird result in ELK

We are using the ELK stack for log processing. We see that some of the events from Steeltoe result in some weird entries.

The following message is logged
CancelAsync "http://server/eureka/apps/application:5101", status: OK

ELK reports the following template being used:
CancelAsync {0}, status: {1}

This results in
0: http://server/eureka/apps/application:5101
1: OK

The key values 1 and 2 doesn't give any meaning.

If the template was updated to this, we would get keys with a bit more meaning.
CancelAsync {Url}, status: {Status}

Eureka Cluster config is not working in the Steeltoe Discovery

I am using the Steeltoe Discovery ClientCore v2.0.1. Eureka Cluster mode configuration is not working.

Single Instance of the Eureka Server config in the Microservice as follows

  "eureka": {
    "client": {
      "serviceUrl": "http://localhost:8761/eureka/"
      },

The above configuration works fine for single instance of the Eureka Server.

Multi Instances of the Eureka Servers config in the Micro Service as follows
Microservice configuration (appsettings.json)

{
  "Logging": {
    "IncludeScopes": true,
    "LogLevel": {
      "Default": "Information",
      "Pivotal": "Debug",
      "Steeltoe": "Debug"
    }
  },
  "spring": {
    "application": {
      "name": "fortuneService"
    }
  },
  "eureka": {
    "client": {
      "serviceUrl": {
        "defaultZone": "http://localhost:8761/eureka/,http://localhost:8762/eureka/,http://localhost:8763/eureka/"
      },
      "shouldFetchRegistry": true,
      "ValidateCertificates": false,
      "registryFetchIntervalSeconds": 10
    },
    "instance": {
      "appName": "FortuneService",
      "hostName": "localhost",
      "port": 52701,
      "instanceId": "FortuneService2",
      "leaseRenewalIntervalInSeconds": 10,
      "leaseExpirationDurationInSeconds": 5,

      "metadataMap": {
        "zone": "Zone1"
      }
    }
  }
}

The above configuration is not working for Eureka Cluster mode. When I used the above configuration, EurekaClientConfig always set from the Default_ServerServiceUrl
public const string Default_ServerServiceUrl = "http://localhost:8761/eureka/";

Why EurekaClientConfig set the Default_ServerServiceUrl to the EurekaServerServiceUrls? Why it is not taking from configuration(appsettings.json) file?

Missing connection pooling

Every time class EurekaHttpClients connects to Eureka server new HttpClient instance is created. New instances of HttpClient results with too many opened TCP connections. EurekaHttpClient should reuse instance of HttpClient class, for ex. by storing it's reference in field _client, which is already declared.

IDiscoveryClient.ShutdownAsync()

This method doesn't contain much documentation, but I'm guessing that it unregisters any information in Eureka using the asynchronous .NET functionality.

In my .NET Core services, I'm calling it as part of the application shutdown.

appLifetime.ApplicationStopping.Register(() =>
{
    discoveryClient.ShutdownAsync();
});

Since it's a void method, I cannot wait for the call to finish before doing further cleanup. If the process terminates quickly, I'm very unsure what happens to any async infrastructure that is set up to handle the ShutdownAsync() call. Can things be torn down before the method gets around to being called?

Could we get a Task ShutdownAsync() method as well? Then we have more control over things.

How to access eureka server with user/password?

In java version, I use below setting to access Eureka server which has user/password setting.
...
eureka.client.serviceUrl.defaultZone=http://user:password@localhost:11001/eureka/
...
But in Steeltoe .net version, It seem has no effect.Who can help me?

Another question: Steeltoe suport below format(property binding), supprot {cipher} encryp format?

eureka.client.serviceUrl.defaultZone=http://${security.user.name}:${security.user.password}@localhost:11001/eureka/
..
security.user.name=user
security.user.password={cipher}xxxxxxx

Suport simpleinjector IOC

Hello
Can you implement simpleinjector IOC for Discovery, I 've tried it, but server can not be regist to Eureka Server

`

public static class DiscoveryContainerExtensions
 {
     public const string EUREKA_PREFIX = "eureka";

     public static void RegisterDiscoveryClient(this Container container, DiscoveryOptions 
       discoveryOptions,IDiscoveryLifecycle lifecycle = null)
       {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

        if (discoveryOptions == null)
        {
            throw new ArgumentNullException(nameof(discoveryOptions));
        }

        if (discoveryOptions.ClientType == DiscoveryClientType.EUREKA)
        {
            EurekaClientOptions clientOptions = discoveryOptions.ClientOptions as EurekaClientOptions;
            if (clientOptions == null)
            {
                throw new ArgumentException("Missing Client Options");
            }

            container.Register(typeof(IOptionsMonitor<EurekaClientOptions>),()=>new 
        OptionsMonitorWrapper<EurekaClientOptions>(clientOptions),Lifestyle.Singleton);

            var regOptions = discoveryOptions.RegistrationOptions as EurekaInstanceOptions;
            if (regOptions == null)
            {
                clientOptions.ShouldRegisterWithEureka = false;
                regOptions = new EurekaInstanceOptions();
            }

            container.Register(typeof(IOptionsMonitor<EurekaInstanceOptions>),()=>new OptionsMonitorWrapper<EurekaInstanceOptions>(regOptions), Lifestyle.Singleton);

            AddEurekaServices(container, lifecycle);
        }
        else
        {
            throw new ArgumentException("Client type UNKNOWN");
        }
    }

    public static void RegisterDiscoveryClient(this Container container, Action<DiscoveryOptions> setupOptions, IDiscoveryLifecycle lifecycle = null)
    {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

        if (setupOptions == null)
        {
            throw new ArgumentNullException(nameof(setupOptions));
        }

        var options = new DiscoveryOptions();
        setupOptions(options);

        container.RegisterDiscoveryClient(options, lifecycle);
    }

    public static void RegisterDiscoveryClient(this Container container, IConfiguration config, IDiscoveryLifecycle lifecycle = null)
    {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

        if (config == null)
        {
            throw new ArgumentNullException(nameof(config));
        }

        AddDiscoveryServices(container, config, lifecycle);
    }

    public static void StartDiscoveryClient(this Container container)
    {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

       
        container.GetInstance<IDiscoveryClient>();
    }

    private static void AddDiscoveryServices(Container container, IConfiguration config, IDiscoveryLifecycle lifecycle)
    {
        var clientConfigsection = config.GetSection(EUREKA_PREFIX);
        int childCount = clientConfigsection.GetChildren().Count();
        if (childCount > 0)
        {
            var clientSection = config.GetSection(EurekaClientOptions.EUREKA_CLIENT_CONFIGURATION_PREFIX);
            container.RegisterOption<EurekaClientOptions>(clientSection);

            container.RegisterPostConfigure<EurekaClientOptions>((options) =>
            {
               
            });
            var instSection = config.GetSection(EurekaInstanceOptions.EUREKA_INSTANCE_CONFIGURATION_PREFIX);
            container.RegisterOption<EurekaInstanceOptions>(instSection);

            container.RegisterPostConfigure<EurekaInstanceOptions>((options) =>
            {
                EurekaPostConfigurer.UpdateConfiguration(config, options);
            });
            AddEurekaServices(container, lifecycle);
        }
        else
        {
            throw new ArgumentException("Discovery client type UNKNOWN, check configuration");
        }
    }

    private static void AddEurekaServices(Container container, IDiscoveryLifecycle lifecycle)
    {
        container.Register<EurekaApplicationInfoManager>(Lifestyle.Singleton);
        container.Register<EurekaDiscoveryManager>(Lifestyle.Singleton);
        //container.Register<IDiscoveryClient>(() =>

        //    {
        //        return new EurekaDiscoveryClient(container.GetInstance<IOptionsMonitor<EurekaClientOptions>>(),
        //            container.GetInstance<IOptionsMonitor<EurekaInstanceOptions>>(),
        //            container.GetInstance<EurekaApplicationInfoManager>());
        //    } 

        //,Lifestyle.Singleton);
        container.Register<EurekaDiscoveryClient>(Lifestyle.Singleton);
        container.Register<IEurekaHttpClient>(() =>
        {
            return new EurekaHttpClientInternal(container.GetInstance<IOptionsMonitor<EurekaClientOptions>>(),
                container.GetInstance<ILoggerFactory>());
        }, Lifestyle.Singleton);
        if (lifecycle == null)
        {
            container.Register<IDiscoveryLifecycle, ApplicationLifecycle>(Lifestyle.Singleton);
        }
        else
        {

            container.Register<IDiscoveryLifecycle>(()=>lifecycle,Lifestyle.Singleton);
        }
        container.Register<IDiscoveryClient>(()=>container.GetInstance<EurekaDiscoveryClient>(),Lifestyle.Singleton);
    }


    public class EurekaHttpClientInternal : EurekaHttpClient
    {
        private IOptionsMonitor<EurekaClientOptions> _configOptions;

        protected override IEurekaClientConfig Config
        {
            get
            {
                return _configOptions.CurrentValue;
            }
        }

        public EurekaHttpClientInternal(IOptionsMonitor<EurekaClientOptions> config, ILoggerFactory logFactory = null)
        {
            _config = null;
            _configOptions = config ?? throw new ArgumentNullException(nameof(config));
            Initialize(new Dictionary<string, string>(), logFactory);
        }
    }
    public class ApplicationLifecycle : IDiscoveryLifecycle
    {
        private CancellationTokenSource source = new CancellationTokenSource();

        public ApplicationLifecycle()
        {
        }

        public void Shutdown()
        {
            source.Cancel();
        }

        public CancellationToken ApplicationStopping
        {
            get
            {
                return source.Token;
            }
        }
    }

    public class OptionsMonitorWrapper<T> : IOptionsMonitor<T>
    {
        private T _option;

        public OptionsMonitorWrapper(T option)
        {
            _option = option;
        }

        public T CurrentValue => _option;

        public T Get(string name)
        {
            return _option;
        }

        public IDisposable OnChange(Action<T, string> listener)
        {
            return null;
        }
    }
}

`

`

   public static class OptionsContainerExtensions
  {
     public static void RegisterOptions(this Container container)
    {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

        container.Register(typeof(IOptions<>),typeof(OptionsManager<>),Lifestyle.Singleton);
        container.Register(typeof(IOptionsMonitor<>), typeof(OptionsMonitor<>), Lifestyle.Singleton);
        container.Register(typeof(IOptionsMonitorCache<>), typeof(OptionsCache<>), 
  Lifestyle.Singleton);
        container.Register(typeof(IOptionsSnapshot<>), typeof(OptionsManager<>), Lifestyle.Singleton);
        container.Register(typeof(IOptionsFactory<>), typeof(OptionsFactory<>), Lifestyle.Singleton);
    }

    public static void RegisterOption<TOption>(this Container container, IConfiguration config) where TOption : class
    {
        container.RegisterOption<TOption>(Options.DefaultName, config);
    }

    public static void RegisterOption<TOption>(this Container container, string name, IConfiguration config)where TOption : class
    {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

        if (config == null)
        {
            throw new ArgumentNullException(nameof(config));
        }

        container.Register<IOptionsChangeTokenSource<TOption>>(()=>new ConfigurationChangeTokenSource<TOption>(name, config), Lifestyle.Singleton);
        //container.Register<IConfigureOptions<TOption>>(()=>new NamedConfigureFromConfigurationOptions<TOption>(name, config), Lifestyle.Singleton);

        container.Register< IEnumerable<IOptionsChangeTokenSource<TOption>>>(() =>new List<IOptionsChangeTokenSource<TOption>>(){ new ConfigurationChangeTokenSource<TOption>(name, config)}, Lifestyle.Singleton);
        //container.Register<IEnumerable<IConfigureOptions<TOption>>>(() =>new List<IConfigureOptions<TOption>>(){ new NamedConfigureFromConfigurationOptions<TOption>(name, config)}, Lifestyle.Singleton);
    }

    public static void RegisterPostConfigure<TOptions>(this Container container, Action<TOptions> configureOptions)where TOptions : class
    {
        container.RegisterPostConfigure(Options.DefaultName, configureOptions);
    }

    public static void RegisterPostConfigure<TOptions>(this Container container, string name, Action<TOptions> configureOptions)
        where TOptions : class
    {
        if (container == null)
        {
            throw new ArgumentNullException(nameof(container));
        }

        if (configureOptions == null)
        {
            throw new ArgumentNullException(nameof(configureOptions));
        }

        container.Register(typeof(IPostConfigureOptions<TOptions>),()=>new PostConfigureOptions<TOptions>(name, configureOptions),Lifestyle.Singleton);
        //container.Register<IEnumerable<IPostConfigureOptions<TOptions>>>(() => new List<IPostConfigureOptions<TOptions>>() { new PostConfigureOptions<TOptions>(name, configureOptions) }, Lifestyle.Singleton);
    }
}

`

Registration error

I get the following error when I register a new app in Eureka:
"{
'timestamp':1508239392780,
'status':500,
'error':'Internal Server Error',
'exception':'com.thoughtworks.xstream.converters.ConversionException',
'message':'java.lang.Boolean cannot be cast to java.lang.String : java.lang.Boolean cannot be cast to java.lang.String
---- Debugging information ----
nmessage : java.lang.Boolean cannot be cast to java.lang.String
ncause-exception : java.lang.ClassCastException
ncause-message : java.lang.Boolean cannot be cast to java.lang.String
nclass : com.netflix.appinfo.InstanceInfo
nrequired-type : com.netflix.appinfo.InstanceInfo
nconverter-type : org.springframework.cloud.netflix.eureka.DataCenterAwareMarshallingStrategy$DataCenterAwareConverter
nline number : -1
nversion : 1.1.147
-------------------------------',
'path':'/eureka/apps/DOTNET-DEMO-SERVICE'
"

My config is:
"
"spring": {
"application": {
"name": "myDotnetService"
}
},
"eureka": {
"client": {
"serviceUrl": "http://my-eureka-instance:8761/eureka/",
"shouldRegisterWithEureka":true,
"shouldFetchRegistry": false
},
"instance": {
"app": "myDotnetService",
"hostName":"my-host",
"port": "6000"
}
"

But if i change type of property "Enable" in JsonPortWrapper to String all work as need:
[JsonProperty("@enabled")]
public String Enabled { get; private set; }

Should host name use FQDN?

 public string GetHostName(bool refresh)
        {
            
            if (_hostName != null)
                return _hostName;

            var boundValue = GetString(Eureka?.Instance?.HostName, null);
            if (!string.IsNullOrEmpty(boundValue))
                return boundValue;
            

            if (refresh || string.IsNullOrEmpty(_thisHostName))
                _thisHostName = Dns.GetHostName();
            return _thisHostName;
        }

The current code is using Dns.GetHostName() which only returns the first part of a FQDN. For our installation it became very inconsistent with all the Java registered services.

To fix it we used code like this.

var hostEntry = Dns.GetHostEntryAsync(Dns.GetHostName()).GetAwaiter().GetResult();

 var builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", false, true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true, true)
		.AddInMemoryCollection( new[]
		{
			new KeyValuePair<string,string>("eureka:instance:hostName", hostEntry.HostName)
		}).AddEnvironmentVariables();

Should the GetHostName() be changed to use Dns.GetHostEntryAsync() by default?

Registering with Eureka discovery server working, but renew failing.

Hello, I am experiencing a weird issue with the Steeltoe discovery client. I have an instance of a Eureka server stood up in PCF, and have followed the Fortune-Teller examples for connecting to this registry. The connection works fine, and I can see the service being registered and listed on the 'Manage' page of the discovery service. After a little while though, usually about 30 seconds to 2 minutes, the service de-registers itself and I see the following in the logs on PCF.

2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at System.Threading.Tasks.ValueTask1.get_Result() 2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) 2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask)
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at Steeltoe.Discovery.Eureka.Transport.EurekaHttpClient.SendHeartBeatAsync(String appName, String id, InstanceInfo info, InstanceStatus overriddenStatus)
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] at Steeltoe.Discovery.Eureka.DiscoveryClient.RenewAsync()
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] �[40m�[37mdbug�[39m�[22m�[49m: Steeltoe.Discovery.Eureka.DiscoveryClient[0]
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] Renew failed
2018-10-29T13:02:46.276-04:00 [APP/PROC/WEB/0] [OUT] HeartBeat failed

Here is my appsettings.json

{ "Logging": { "LogLevel": { "Default": "Warning" } }, /* Spring options for steeltoe compatibility */ "spring": { "application": { "name": "message-generator-core" }, "cloud": { "discovery": { "registrationMethod": "direct" } } }, /* Configure the connection to the eureka discovery service. */ "eureka": { "client": { "serviceUrl": "http://localhost:8761/eureka/", "shouldFetchRegistry": false }, "instance": { "port": 5000, "securePortEnabled": true } } }

If anybody has any idea what may be causing this, I would greatly appreciate any insight! If you need any more info from me, please let me know.

Does eureka:client:serviceUrl support multiple eureka servers in the config?

Currently, I use config:
"eureka": {
"client": {
"serviceUrl": "http://server1:1234/eureka/",
"shouldFetchRegistry": false,
"validate_certificates": false
},
it works. but I have two HA enabled eureka servers : server1, server2, but following config NOT work:

"eureka": {
"client": {
"serviceUrl": "http://server1:1234/eureka/,http://server2:2234/eureka/",
"shouldFetchRegistry": false,
"validate_certificates": false
},

And I see all the issues about this, I confused that have we fix this issue yet?
Do we have a plan?

Why ip address and hostname settings are not considered

I am trying to change the hostname and the ip adress that discovery client uses to register by setting it in the config json -
"eureka": {
"client": {
"serviceUrl": "http://52.77.123.70:8761/eureka/",
"shouldFetchRegistry": false
},
"instance": {
"hostname": "localhost",
"ipAddress": "127.0.0.1"
"preferIpAddress"=true,
"port": 5001
}
}

Looks like hostname, ipAddress, preferIpAddress are not being considered. Any plans of adding this?

provide Client ID and client secret in steel Toe

Hi,

I'm using Eureka in Private PCF. The following is my eureka configuration in appSettings.json.
"eureka": {
"client": {
"validate_certificates": false,
"serviceUrl": "https://eureka-82f81597-d68d-462a-89ce-3d68c58b9f29.xxx.com/eureka",
"shouldFetchRegistry": false
},
"instance": {
"hostName": "eurekaSP.xxx.com",
"port": 80
}
}
How do I provide the client id and client secret for this eureka service in appSettings.json. This is because I'm using the eureka from PCF market place and that requires a client ID and client secret.

Why my service registed host is localhost.localdomain?

my appsetting.json
{
"spring": {
"application": {
"name": "ServiceNetCore"
}
},
"eureka": {
"client": {
"serviceUrl": "http://192.168.134.192:8761/eureka/",
"shouldFetchRegistry": false
,"shouldRegisterWithEureka":true
//"validate_certificates": false
},
"instance": {
"hostName":"192.168.1.125",
"port": 5001,
"preferIpAddress":true
}
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information",
"Pivotal": "Debug",
"Steeltoe": "Debug"
}
}
}

but the registed adress is localhost.localdomain

Update to RC2?

Will there be an update to RC2 ? :) Cause I havn't seen any working service discovery for asp.net core RC2 yet.

Cannot evict service from eureka.

Hello,
I am using it with a .net framework project and everything including the service discovery, consume and zuul is fine. The problem is when I stop my service, the published service stays as registered on the eureka like forever. I wait 5 minutes and it still remains. So I turned off the self preservation of eureka and the service still remains. Unless I restart the eureka server the service stays registered. I don't think there is something wrong with eureka because my java project works fine. Is there anything wrong?
thanks!

Consul Support

Kindly i want to ask when will you support consul service registry ?

Host Name and IP Address not computing on Mac and Docker

When I set manually hostname and ipAddress it is registering to Eureka server

....
"eureka": {
    "client": {
      "serviceUrl": "http://localhost:8761/eureka/",
      "shouldRegisterWithEureka": true,
      "shouldFetchRegistry": false,
      "ValidateCertificates":  false
    },
    "instance": {
      "hostname" : "localhost",
      "ipAddress": "127.0.0.1",
      "port": 5000
    }
  } ....

I removed static hostname and ipAddress and it is giving me BadRequest on the registration, here is request data:

{
    "instance": {
        "instanceId": "Users-MacBook-Pro.local:menu-service:5000",
        "app": "MENU-SERVICE",
        "appGroupName": null,
        "ipAddr": null,
        "sid": "na",
        "port": {
            "@enabled": true,
            "$": 5000
        },
        "securePort": {
            "@enabled": false,
            "$": 443
        },
        "homePageUrl": "http://Users-MacBook-Pro.local:5000/",
        "statusPageUrl": "http://Users-MacBook-Pro.local:5000/info",
        "healthCheckUrl": "http://Users-MacBook-Pro.local:5000/health",
        "secureHealthCheckUrl": null,
        "vipAddress": "menu-service",
        "secureVipAddress": "menu-service",
        "countryId": 1,
        "dataCenterInfo": {
            "@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
            "name": "MyOwn"
        },
        "hostName": "Users-MacBook-Pro.local",
        "status": "UP",
        "overriddenstatus": "UNKNOWN",
        "leaseInfo": {
            "renewalIntervalInSecs": 30,
            "durationInSecs": 90,
            "registrationTimestamp": 0,
            "lastRenewalTimestamp": 0,
            "renewalTimestamp": 0,
            "evictionTimestamp": 0,
            "serviceUpTimestamp": 0
        },
        "isCoordinatingDiscoveryServer": false,
        "metadata": {
            "@class": "java.util.Collections$EmptyMap"
        },
        "lastUpdatedTimestamp": 1552240926659,
        "lastDirtyTimestamp": 1552240926659,
        "actionType": "ADDED"
    }
}

Expected result ipAddress should not be null to be able to use preferIpAddress: true
TargetFramework: netcoreapp2.1
NuGet Package: Pivotal.Discovery.ClientCore: 2.1.0

Getting this error Peer certificate cannot be authenticated with given CA certificate

Hi , I am trying to see how Service Discovery works in PCF Dev. I logged in to pcf dev using cf login -a https://api.local.pcfdev.io --skip-ssl-validation and published both my client and service applications. when i call the client url , i am getting HTTP 500 error, when i saw the logs it says -

2017-04-28T17:26:01.50-0500 [APP/PROC/WEB/0] OUT fail: Steeltoe.Discovery.Eureka.Transport.EurekaHttpClient[0]
2017-04-28T17:26:01.50-0500 [APP/PROC/WEB/0] OUT DoGetApplicationsAsync Exception: System.Net.Http.HttpRequestExce
ption: An error occurred while sending the request. ---> System.Net.Http.CurlException: Peer certificate cannot be authe
nticated with given CA certificates

please help me on this error:

As I was reading through : http://steeltoe.io/docs/steeltoe-discovery/#1-2-2-1-settings-to-discover
this they are saying i may run into ssl certificate issues, is this error related with this ??

DiscoveryManager.Instance.Initialize(clientConfig) NullReferenceException

I have the following code as I followed the readme on https://github.com/SteeltoeOSS/Discovery/tree/master/src/Steeltoe.Discovery.Eureka.Client

    ```

private IEurekaClient _client;

    public DiscoveryService()
    {
        // If there is not valid client, initialize it
        if (DiscoveryManager.Instance.Client == null)
            this.Init();

        this._client = DiscoveryManager.Instance.Client;
    }

    private void Init()
    {
        // Discovery Url
        EurekaClientConfig clientConfig = new EurekaClientConfig()
        {
            EurekaServerServiceUrls = "https://localhost:8080/eureka/"
        };

        // Initialize client
        // No services to register, we're only getting data
        DiscoveryManager.Instance.Initialize(clientConfig);
    }

When I run the code I get the following exception:

{"Object reference not set to an instance of an object."}

Here is the StackTrace:
   at Steeltoe.Discovery.Eureka.DiscoveryClient..ctor(IEurekaClientConfig clientConfig, IEurekaHttpClient httpClient, ILoggerFactory logFactory)
   at Steeltoe.Discovery.Eureka.DiscoveryManager.Initialize(IEurekaClientConfig clientConfig, IEurekaHttpClient httpClient, ILoggerFactory logFactory)
   at Steeltoe.Discovery.Eureka.DiscoveryManager.Initialize(IEurekaClientConfig clientConfig, ILoggerFactory logFactory)
   at DiscoveryService.DiscoveryService.Init() in *****
   at Microsoft.Practices.ObjectBuilder2.DynamicBuildPlanGenerationContext.<>c__DisplayClass1.<GetBuildMethod>b__0(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
   at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)

Proxy settings are unused

I am trying to send requests both from client and server through a proxy but the proxy settings to not seem to be respected. I can't actually find any use of ProxyHost or ProxyPort outside of loading the configuration settings. They seem ignored after that. Are they not supported?

Failing to fetch registry

Hi,

I'm in the process of building a POC .NetCore app, and stand it up on our business's instance of PCF. In the PoC, I'm utilizing the service registry and the circuitbreaker. I'm running into issues, however, with fetching the registry from my consuming service. I've tried several different configurations in my appsettings.json, and I've gotten it to work, kind of, for all of 15 seconds. I was able to fetch the registry, but then when it tried to renew itself, it failed out again. The logs in PCF are not very ellucidating either, but I've copied them below just in case.

2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] DoGetApplicationsAsync Failed
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] System.Net.Http.HttpRequestException: No such device or address ---> System.Net.Sockets.SocketException: No such device or address
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] --- End of inner exception stack trace ---
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Threading.Tasks.ValueTask1.get_Result() 2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) 2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask)
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts) 2018-10-29T13:09:20.228-04:00 [APP/PROC/WEB/0] [OUT] at Steeltoe.Discovery.Eureka.Transport.EurekaHttpClient.DoGetApplicationsAsync(String path, ISet1 regions)
2018-10-29T13:09:20.230-04:00 [APP/PROC/WEB/0] [OUT] �[41m�[30mfail�[39m�[22m�[49m: Steeltoe.Discovery.Eureka.DiscoveryClient[0]
2018-10-29T13:09:20.230-04:00 [APP/PROC/WEB/0] [OUT] FetchRegistry Failed
2018-10-29T13:09:20.230-04:00 [APP/PROC/WEB/0] [OUT] System.Net.Http.HttpRequestException: No such device or address ---> System.Net.Sockets.SocketException: No such device or address
2018-10-29T13:09:20.230-04:00 [APP/PROC/WEB/0] [OUT] at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
2018-10-29T13:09:20.230-04:00 [APP/PROC/WEB/0] [OUT] --- End of inner exception stack trace ---

DoGetApplicationsAsync Failed

When a service is registered without instanceId I have following error

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.Collections.Concurrent.ConcurrentDictionary`2.ThrowKeyNullException()
   at System.Collections.Concurrent.ConcurrentDictionary`2.set_Item(TKey key, TValue value)
   at Steeltoe.Discovery.Eureka.AppInfo.Application.FromJsonApplication(JsonApplication japp)
   at Steeltoe.Discovery.Eureka.AppInfo.Applications.FromJsonApplications(JsonApplications japps)
   at Steeltoe.Discovery.Eureka.Transport.EurekaHttpClient.DoGetApplicationsAsync(String path, ISet`1 regions)

Error message in Eureka server dashboard

when .net service is registered with Eureka server, there is an error message in red:
EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

maybe the reason is the .net client is not sending heartbeat message to the server.
Is it possible to add the mechanism or remove the error message somehow?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.