Go 以编程方式启动的领事代理未打开HTTP端口
我试着用他们的Golang建立一个领事代理人。 服务器本身会启动,但我无法与之交互,因为它不会开始侦听传入的HTTP请求 启动代理的我的代码:Go 以编程方式启动的领事代理未打开HTTP端口,go,consul,Go,Consul,我试着用他们的Golang建立一个领事代理人。 服务器本身会启动,但我无法与之交互,因为它不会开始侦听传入的HTTP请求 启动代理的我的代码: //create the logwriter writer := bytes.NewBuffer(server.log) agentConfig := agent.DefaultConfig() agentConfig.BindAddr = "127.0.0.1" agentConfig.DevMode = true agentConfig.Boots
//create the logwriter
writer := bytes.NewBuffer(server.log)
agentConfig := agent.DefaultConfig()
agentConfig.BindAddr = "127.0.0.1"
agentConfig.DevMode = true
agentConfig.Bootstrap = true
agentConfig.Server = true
agentConfig.DataDir = "/tmp"
agentConfig.Ports.HTTP = 8500
agentConfig.Ports.HTTPS = -1
//agentConfig.AdvertiseAddr = "127.0.0.1"
//agentConfig.EnableUi = true
agentConfig.Addresses.HTTP = "127.0.0.1"
glog.Infof("Agent config: %+v", agentConfig)
agent, err := agent.Create(agentConfig, writer)
if err != nil {
t.Fatalf("Error starting consul agent: %v", err)
}
启动时生成的配置如下所示:
Agent config: &{DevMode:true Bootstrap:true BootstrapExpect:0
Server:true Datacenter:dc1 DataDir:/tmp DNSRecursor: DNSRecursors:[] DNSConfig:{NodeTTL:0 NodeTTLRaw: ServiceTTL:map[] ServiceTTLRaw:map[]
AllowStale:false EnableTruncate:false UDPAnswerLimit:3 MaxStale:5s
MaxStaleRaw: OnlyPassing:false} Domain:consul. EncryptKey:
LogLevel:INFO NodeName: ClientAddr:127.0.0.1 BindAddr:127.0.0.1
AdvertiseAddr: AdvertiseAddrs:{SerfLan:<nil> SerfLanRaw: SerfWan:<nil>
SerfWanRaw: RPC:<nil> RPCRaw:} AdvertiseAddrWan:
TranslateWanAddrs:false Ports:{DNS:8600 HTTP:8500 HTTPS:-1 RPC:8400
SerfLan:8301 SerfWan:8302 Server:8300} Addresses:{DNS: HTTP:127.0.0.1
HTTPS: RPC:} TaggedAddresses:map[] LeaveOnTerm:false SkipLeaveOnInt:
<nil> Telemetry:{StatsiteAddr: StatsdAddr: StatsitePrefix:consul
DisableHostname:false DogStatsdAddr: DogStatsdTags:[]} Protocol:2
EnableDebug:false VerifyIncoming:false VerifyOutgoing:false VerifyServerHostname:false CAFile: CertFile: KeyFile: ServerName:
StartJoin:[] StartJoinWan:[] RetryJoin:[] RetryMaxAttempts:0
RetryInterval:30s RetryIntervalRaw: RetryJoinWan:[]
RetryMaxAttemptsWan:0 RetryIntervalWan:30s RetryIntervalWanRaw:
ReconnectTimeoutLan:0 ReconnectTimeoutLanRaw: ReconnectTimeoutWan:0
ReconnectTimeoutWanRaw: EnableUi:false UiDir: PidFile:
EnableSyslog:false SyslogFacility:LOCAL0 RejoinAfterLeave:false
CheckUpdateInterval:5m0s CheckUpdateIntervalRaw: ACLToken:
ACLMasterToken: ACLDatacenter: ACLTTL:30s ACLTTLRaw:
ACLDefaultPolicy:allow ACLDownPolicy:extend-cache Watches:[]
DisableRemoteExec:false DisableUpdateCheck:false
DisableAnonymousSignature:false HTTPAPIResponseHeaders:map[]
AtlasInfrastructure: AtlasToken: AtlasACLToken: AtlasJoin:false
AtlasEndpoint: AEInterval:1m0s DisableCoordinates:false
SyncCoordinateRateTarget:64 SyncCoordinateIntervalMin:15s Checks:[]
Services:[] ConsulConfig:<nil> Revision: Version: VersionPrerelease:
WatchPlans:[] UnixSockets:{UnixSocketPermissions:{Usr: Grp: Perms:}}
SessionTTLMin:0 SessionTTLMinRaw: Reap:<nil>}
我们非常感谢您提供的每一个运行提示:)确保所有必需的端口都已打开:
- 服务器RPC(默认8300)
- Serf LAN(默认8301)
- Serf WAN(默认8302)
- HTTP API(默认值8500)
- DNS接口(默认值8600)
确保所有需要的端口都已打开:
- 服务器RPC(默认8300)
- Serf LAN(默认8301)
- Serf WAN(默认8302)
- HTTP API(默认值8500)
- DNS接口(默认值8600)
你试过在0.0.0.0上听吗?你不能在
0.0.0.0
上听。这导致:无法获取播发地址:找到多个专用IP。请配置一个。
是否尝试在0.0.0.0上侦听?您无法在0.0.0.0
上侦听。这导致:无法获取播发地址:找到多个专用IP。请配置一个。
storage.t 16820 felix 5u IPv4 469866 0t0 TCP localhost:8300 (LISTEN)
storage.t 16820 felix 6u IPv4 469867 0t0 TCP localhost:8301 (LISTEN)
storage.t 16820 felix 7u IPv4 469868 0t0 UDP localhost:8301
storage.t 16820 felix 8u IPv4 469869 0t0 TCP localhost:8302 (LISTEN)
storage.t 16820 felix 9u IPv4 469870 0t0 UDP localhost:8302