TGow
TGow

Reputation: 1

Services not registering with Eureka Server using Owin, SteelToe/Autofac running as a Windows Service

Web Services are not registering with Eureka Server from a OWIN SelfHosted console application with Steeltoe/Autofac libraries running as a Windows Service.

//container.StartDiscoveryClient(); does register with Eureka server in another ASP.net app but not in the Console app described above.

The Services runs correctly running in Postman as a client getting the responses we are looking for.

Startup.cs:

ApplicationConfig.RegisterConfig("development");

            var builder = new ContainerBuilder();
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.Register(c => new Logger()).As<ILogger>().InstancePerRequest();
            builder.RegisterDiscoveryClient(ApplicationConfig.Configuration);
            builder.RegisterType<Diw.Persist.DiwData>().As<Diw.Persist.IDiwData>().InstancePerRequest();
            builder.RegisterType<EwsService>().InstancePerRequest();
            builder.RegisterType<HubData.Persist.HubDataData>().InstancePerRequest();
            builder.RegisterType<Icm.Persist.IcmData>().InstancePerRequest();

            var container = builder.Build();
            config.DependencyResolver = new AutofacWebApiDependencyResolver(container);

            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(config);
            app.UseWebApi(config);

Services should show under instances registered with Eureka Server

Upvotes: 0

Views: 433

Answers (1)

Tim
Tim

Reputation: 2707

There are possibly more factors in play than what you've shared so far, so I went ahead and updated one of the Steeltoe samples to also work with a self-hosted OWIN service so you could at least see a basic working example. https://github.com/SteeltoeOSS/Samples/tree/2.x/Discovery/src/AspDotNetAutofac

Self-Hosting OWIN can be tricky, for best results you probably don't want it running under IIS at all, so make sure you're running it as a console app during development (as this Steeltoe sample does)

Upvotes: 0

Related Questions