kitex的默认端口是8888,不修改会报错
2021/12/01 21:12:03.019779 server.go:79: [Info] KITEX: server listen at: :8888 2021/12/01 21:12:03.029125 server.go:187: [Error] KITEX: received error and exit: listen tcp :8888: bind: address already in use 2021/12/01 21:12:03 listen tcp :8888: bind: address already in use
修改后
package main import ( "log" "net" api "github.com/cloudwego/kitex-examples/hello/kitex_gen/api/hello" "github.com/cloudwego/kitex/server" ) func main() { addr, _ := net.ResolveTCPAddr("tcp", ":8801") var opts []server.Option opts = append(opts, server.WithServiceAddr(addr)) svr := api.NewServer(new(HelloImpl), opts...) err := svr.Run() if err != nil { log.Println(err.Error()) } }
结果:
2022/08/18 18:15:21.814640 server.go:76: [Info] KITEX: server listen at [::]:8801
发表评论 取消回复