Closed Ashion closed 6 months ago
it seems in config.go will set the ip to global local ip when the ip in configure is empty.
// RepairConfig repairs the Config by filling in some fields with default values.
func RepairConfig(cfg *Config) error {
// nic -> ip
if err := repairServiceIPWithNic(cfg); err != nil {
return err
}
// set default read buffer size
if cfg.Global.ReadBufferSize == nil {
readerSize := codec.DefaultReaderSize
cfg.Global.ReadBufferSize = &readerSize
}
codec.SetReaderSize(*cfg.Global.ReadBufferSize)
// protocol network ip empty
for _, serviceCfg := range cfg.Server.Service {
setDefault(&serviceCfg.Protocol, cfg.Server.Protocol)
setDefault(&serviceCfg.Network, cfg.Server.Network)
setDefault(&serviceCfg.IP, cfg.Global.LocalIP)
setDefault(&serviceCfg.Transport, cfg.Server.Transport)
setDefault(&serviceCfg.Address, net.JoinHostPort(serviceCfg.IP, strconv.Itoa(int(serviceCfg.Port))))
// server async mode by default
if serviceCfg.ServerAsync == nil {
enableServerAsync := true
serviceCfg.ServerAsync = &enableServerAsync
}
// writev disabled by default
if serviceCfg.Writev == nil {
enableWritev := false
serviceCfg.Writev = &enableWritev
}
if serviceCfg.Timeout == 0 {
serviceCfg.Timeout = cfg.Server.Timeout
}
if serviceCfg.Idletime == 0 {
serviceCfg.Idletime = defaultIdleTimeout
if serviceCfg.Timeout > defaultIdleTimeout {
serviceCfg.Idletime = serviceCfg.Timeout
}
}
}
setDefault(&cfg.Client.Namespace, cfg.Global.Namespace)
for _, backendCfg := range cfg.Client.Service {
repairClientConfig(backendCfg, &cfg.Client)
}
return nil
}
Try explicitly setting 0.0.0.0
:
ip: 0.0.0.0
port: 9092
so the unspecified "ip" not indicated that listen to all interface, it will choose lastest specified "ip" in service or local ip specified. it seems an uncertain operation, maybe it can mentioned in docs.
Try explicitly setting
0.0.0.0
:ip: 0.0.0.0 port: 9092
What version of tRPC-Go are you using?
master
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have service on both restful and trpc, and needs the restful listen on all addresses, trpc listen on localhost(127.0.0.1) it seems cannot work likes this.
server: # server configuration. app: test # business application name. server: helloworld # service process name. bin_path: /usr/local/trpc/bin/ # paths to binary executables and framework configuration files. conf_path: /usr/local/trpc/conf/ # paths to business configuration files. data_path: /usr/local/trpc/data/ # paths to business data files. service: # business service configuration,can have multiple.
ip: 127.0.0.1 # the service listening ip address, can use the placeholder ${ip}, choose one of ip and nic, priority ip.
port: 9092 # the service listening port, can use the placeholder ${port}. network: tcp # the service listening network type, tcp or udp. protocol: restful # application layer protocol. NOTE restful service this is restful. timeout: 1000 # maximum request processing time in milliseconds. idletime: 300000 # connection idle time in milliseconds.
plugins: # plugin configuration. log: # log configuration. default: # default log configuration, support multiple outputs.
What did you expect to see?
trpc.test.helloworld.Greeter listen on :9092 trpc service:trpc.test.helloworld.Greeter1 listen on 127.0.0.1:9093
What did you see instead?