用在etcd中注册发现服务,服务能成功访问,却出现KITEX: processing request error, remoteService=,
本人把kitex中的官方案例改成proto格式进行学习中出现了服务调用注册成功但是服务端出现以下报错
2024/03/02 19:28:21.320220 default_server_handler.go:242: [Error] KITEX: processing request error, remoteService=, remoteAddr=127.0.0.1:51069, error=default codec read failed: read tcp 127.0.0.1:8890->127.0.0.1:51069: wsarecv: An existing connection was forcibly closed by the remote host.
原先客户端代码如下
cl, err := itemservice.NewClient("example.shop.item",
client.WithResolver(r),
)
但是在加入客户端信息之后仍然有相同报错
cl, err := itemservice.NewClient("example.shop.item",
client.WithResolver(r),
client.WithClientBasicInfo(
&rpcinfo.EndpointBasicInfo{
ServiceName: "example.shop.item",
},
),
)
所应用的版本信息如下
github.com/cloudwego/fastpb v0.0.4
github.com/cloudwego/kitex v0.8.0
github.com/kitex-contrib/registry-etcd v0.2.1
google.golang.org/protobuf v1.32.0
请告诉我如何修改它
cc @cqqqq777
是否能提供一个可复现的demo,我排查一下。比较怀疑和网络环境相关。
请使用该仓库的etcd分支,demo的启动和一些描述请看readme文件,仓库地址如下https://github.com/onenewcode/mykitex
我使用你的代码未做修改,可以跑起来,你现在跑还是报这个问题吗
是的,一旦客户端发起远程调用,服务端就会出现这个报错,请问您有这个问题吗?这只是个例吗?
没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题
试试升级到最新版本:go get github.com/kitex-contrib/[email protected]
没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题
在本地win,上装了etcd,进行测试仍然有这个问题,在本地虚拟机中进行测试是我同样结果
试试升级到最新版本:go get github.com/kitex-contrib/[email protected]
新版本可能和kitex v0.9.0存在兼容问题。
go get github.com/kitex-contrib/[email protected]
go mod tidy
在运行上述代码后,启动demo,服务端出现以下错误。
# github.com/cloudwego/kitex/pkg/utils
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:54:54: not enough arguments in call to t.tProt.WriteMessageBegin
have (string, thrift.TMessageType, int32)
want (context.Context, string, thrift.TMessageType, int32)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:57:21: not enough arguments in call to msg.Write
have (thrift.TProtocol)
want (context.Context, thrift.TProtocol)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:60:11: not enough arguments in call to t.tProt.WriteMessageEnd
have ()
want (context.Context)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:74:35: not enough arguments in call to t.tProt.ReadMessageBegin
have ()
want (context.Context)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:79:27: not enough arguments in call to exception.Read
have (thrift.TProtocol)
want (context.Context, thrift.TProtocol)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:82:12: not enough arguments in call to t.tProt.ReadMessageEnd
have ()
want (context.Context)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:88:20: not enough arguments in call to msg.Read
have (thrift.TProtocol)
want (context.Context, thrift.TProtocol)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:91:2: not enough arguments in call to t.tProt.ReadMessageEnd
have ()
want (context.Context)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:100:21: not enough arguments in call to msg.Write
have (thrift.TProtocol)
want (context.Context, thrift.TProtocol)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:114:20: not enough arguments in call to msg.Read
have (thrift.TProtocol)
want (context.Context, thrift.TProtocol)
D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:114:20: too many errors
退回0.2.1版本demo才能运行
需要在项目的 go.mod 里加上 replace github.com/apache/thrift => github.com/apache/thrift v0.13.0
试试升级到最新版本:go get github.com/kitex-contrib/[email protected]
新版本可能和kitex v0.9.0存在兼容问题。
go get github.com/kitex-contrib/[email protected] go mod tidy在运行上述代码后,启动demo,服务端出现以下错误。
# github.com/cloudwego/kitex/pkg/utils D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:54:54: not enough arguments in call to t.tProt.WriteMessageBegin have (string, thrift.TMessageType, int32) want (context.Context, string, thrift.TMessageType, int32) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:57:21: not enough arguments in call to msg.Write have (thrift.TProtocol) want (context.Context, thrift.TProtocol) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:60:11: not enough arguments in call to t.tProt.WriteMessageEnd have () want (context.Context) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:74:35: not enough arguments in call to t.tProt.ReadMessageBegin have () want (context.Context) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:79:27: not enough arguments in call to exception.Read have (thrift.TProtocol) want (context.Context, thrift.TProtocol) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:82:12: not enough arguments in call to t.tProt.ReadMessageEnd have () want (context.Context) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:88:20: not enough arguments in call to msg.Read have (thrift.TProtocol) want (context.Context, thrift.TProtocol) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:91:2: not enough arguments in call to t.tProt.ReadMessageEnd have () want (context.Context) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:100:21: not enough arguments in call to msg.Write have (thrift.TProtocol) want (context.Context, thrift.TProtocol) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:114:20: not enough arguments in call to msg.Read have (thrift.TProtocol) want (context.Context, thrift.TProtocol) D:\software\golibrary\pkg\mod\github.com\cloudwego\[email protected]\pkg\utils\thrift.go:114:20: too many errors退回0.2.1版本demo才能运行
没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题
在本地win,上装了etcd,进行测试仍然有这个问题,在本地虚拟机中进行测试是我同样结果
windows有问题?虚拟机是linux,没问题?
没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题
在本地win,上装了etcd,进行测试仍然有这个问题,在本地虚拟机中进行测试是我同样结果
windows有问题?虚拟机是linux,没问题?
尝试过的云服务,win,虚拟机,都有这个问题,客户端调用服务端,服务端就会出现以下报错
default_server_handler.go:259: [Error] KITEX: processing request error, remoteService=, remoteAddr=127.0.0.1:62659, error=default codec read failed: read tcp 127.0.0.1:8890->127.0.0.1:62659: wsarecv: An existing connection was forcibly closed by the remote host.
是否能tcpdump抓包来看下?从报错来看是客户端提前关闭连接了。
registry-etcd 与 kitex 新版本不存在兼容问题,报错是因为需要在 Go mod 锁定 Thrift 版本。 replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 示例源码在这里:https://github.com/cloudwego/kitex-examples/tree/main/basic/example_shop
这是一个代码问题,原本的代码只调用一次注册的服务,客户端程序直接结束,服务端程序便会出现这个错误,如果把客户端程序改成循环调用即可。
这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。