简体   繁体   English

服务未使用作为Windows服务运行的Owin,SteelToe / Autofac向Eureka Server注册

[英]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. Web服务没有从带有Windows服务的Steeltoe / Autofac库的OWIN SelfHosted控制台应用程序向Eureka Server注册。

//container.StartDiscoveryClient(); //container.StartDiscoveryClient(); does register with Eureka server in another ASP.net app but not in the Console app described above. 确实在另一个ASP.net应用程序中向Eureka服务器注册,但没有在上述控制台应用程序中注册。

The Services runs correctly running in Postman as a client getting the responses we are looking for. 作为客户端,我们可以在Postman中正确运行服务,以获取我们正在寻找的响应。

Startup.cs: Startup.cs:

ApplicationConfig.RegisterConfig("development"); 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 服务应显示在已向Eureka Server注册的实例下

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. 影响因素可能比到目前为止共享的更多,因此,我继续进行并更新了Steeltoe示例之一,使其也可以与自托管的OWIN服务一起使用,因此您至少可以看到一个基本的工作示例。 https://github.com/SteeltoeOSS/Samples/tree/2.x/Discovery/src/AspDotNetAutofac 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) 自托管OWIN可能很棘手,为获得最佳结果,您可能根本不希望它在IIS下运行,因此请确保在开发过程中将其作为控制台应用程序运行(如此Steeltoe示例所做的那样)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM