kitex icon indicating copy to clipboard operation
kitex copied to clipboard

用在etcd中注册发现服务,服务能成功访问,却出现KITEX: processing request error, remoteService=,

Open onenewcode opened this issue 1 year ago • 14 comments

本人把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

请告诉我如何修改它

onenewcode avatar Mar 02 '24 11:03 onenewcode

cc @cqqqq777

li-jin-gou avatar Mar 03 '24 15:03 li-jin-gou

是否能提供一个可复现的demo,我排查一下。比较怀疑和网络环境相关。

ppzqh avatar Mar 04 '24 06:03 ppzqh

请使用该仓库的etcd分支,demo的启动和一些描述请看readme文件,仓库地址如下https://github.com/onenewcode/mykitex

onenewcode avatar Mar 04 '24 06:03 onenewcode

我使用你的代码未做修改,可以跑起来,你现在跑还是报这个问题吗

cqqqq777 avatar Mar 04 '24 06:03 cqqqq777

是的,一旦客户端发起远程调用,服务端就会出现这个报错,请问您有这个问题吗?这只是个例吗?

onenewcode avatar Mar 04 '24 06:03 onenewcode

没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题

ppzqh avatar Mar 04 '24 07:03 ppzqh

试试升级到最新版本:go get github.com/kitex-contrib/[email protected]

GuangmingLuo avatar Mar 06 '24 02:03 GuangmingLuo

没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题

在本地win,上装了etcd,进行测试仍然有这个问题,在本地虚拟机中进行测试是我同样结果

onenewcode avatar Mar 06 '24 02:03 onenewcode

试试升级到最新版本: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才能运行

onenewcode avatar Mar 06 '24 02:03 onenewcode

需要在项目的 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才能运行

ppzqh avatar Mar 06 '24 03:03 ppzqh

没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题

在本地win,上装了etcd,进行测试仍然有这个问题,在本地虚拟机中进行测试是我同样结果

windows有问题?虚拟机是linux,没问题?

ppzqh avatar Mar 06 '24 03:03 ppzqh

没有复现这个问题。你本地测试可以复现吗?还是只在云环境下有问题

在本地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.

onenewcode avatar Mar 06 '24 03:03 onenewcode

是否能tcpdump抓包来看下?从报错来看是客户端提前关闭连接了。

ppzqh avatar Mar 06 '24 05:03 ppzqh

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

GuangmingLuo avatar Mar 06 '24 06:03 GuangmingLuo

这是一个代码问题,原本的代码只调用一次注册的服务,客户端程序直接结束,服务端程序便会出现这个错误,如果把客户端程序改成循环调用即可。

onenewcode avatar Mar 29 '24 09:03 onenewcode

这是来自QQ邮箱的假期自动回复邮件。你好,我最近正在休假中,无法亲自回复你的邮件。我将在假期结束后,尽快给你回复。

onenewcode avatar Apr 08 '24 01:04 onenewcode