ocelot consul 的问题 0.0.0.1:5224 错误代码10051

解决

服务发现 — Ocelot Gateway 24.0 文档

官网上说的 做了修改

代码

    public class MyConsulServiceBuilder : DefaultConsulServiceBuilder
    {
        public MyConsulServiceBuilder(IHttpContextAccessor contextAccessor, IConsulClientFactory clientFactory, 
            IOcelotLoggerFactory loggerFactory)
            : base(contextAccessor, clientFactory, loggerFactory) { }

        // Use the agent service IP address as the downstream hostname
        protected override string GetDownstreamHost(ServiceEntry entry, Node node)
            => entry.Service.Address;
    }

 

使用

            builder.Services.AddOcelot().AddConsul<MyConsulServiceBuilder>().AddPolly().AddCacheManager(p =>
            {
                p.WithDictionaryHandle();
            });

 

posted on 2025-04-30 16:00  是水饺不是水饺  阅读(14)  评论(0)    收藏  举报

导航