Closed lgcshy closed 3 months ago
不好意思,没仔细看源码,忘记添加环境变量了
func (s *KeepAliveService) generateEndpoint() error {
if s.endpoint != nil {
return nil
}
for {
port := s.generatePort(10000, 65535)
host := ""
if itf, ok := os.LookupEnv("KRATOS_TRANSPORT_KEEPALIVE_INTERFACE"); ok {
h, err := getIPAddress(itf)
if err != nil {
return err
}
host = h
}
addr := fmt.Sprintf("%s:%d", host, port)
lis, err := net.Listen("tcp", addr)
if err == nil && lis != nil {
s.lis = lis
endpoint, _ := url.Parse("tcp://" + addr)
s.endpoint = endpoint
return nil
}
}
}
: )
` func newApp( ll log.Logger, rr registry.Registrar, gs grpc.Server, rs rabbitmq.Server, ) *kratos.App { return kratos.New( kratos.ID(Service.GetInstanceId()), kratos.Name(Service.Name), kratos.Version(Service.Version), kratos.Metadata(Service.Metadata), kratos.Logger(ll), kratos.Server( gs, rs, ), kratos.Registrar(rr), ) }
func main() { // bootstrap cfg, ll, reg := bootstrap.Bootstrap(Service)
}`
报错:
`INFO service.id=node106-master-1 service.name=consult.service service.version=1.0.0 ts=2024-07-08T11:18:52+08:00 caller=grpc/server.go:212 trace_id= span_id= msg=[gRPC] server listening on: [::]:46433 INFO service.id=node106-master-1 service.name=consult.service service.version=1.0.0 ts=2024-07-08T11:18:52+08:00 caller=rabbitmq@v1.2.8/server.go:101 trace_id= span_id= rabbitmq=server listening on: amqp://admin:admin@10.10.102.106:5672 DEBUG service.id=node106-master-1 service.name=consult.service service.version=1.0.0 ts=2024-07-08T11:18:52+08:00 caller=utils/keepalive.go:56 trace_id= span_id= msg=keep alive service started at [::]:43349 INFO service.id=node106-master-1 service.name=consult.service service.version=1.0.0 ts=2024-07-08T11:18:52+08:00 caller=data/data.go:54 trace_id= span_id= msg=closing the data resources panic: RegisterInstance err retry3times request failed,err=request return error code 400,tcp://:43349
goroutine 1 [running]: main.main()