Kryo serialization fails when the service is both a provider and a consumer(新版本解决了吗?)
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
- [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.
Environment
- Dubbo version: 2.6.2
- Operating System version:Red Hat Enterprise Linux Server release 6.6 (Santiago)
- Java version: 1.8
Step to reproduce this issue
The execution method is as follows:
-
mvn install all the project.
-
testissue2116\summary-server run TestSummaryServer to start summary-server service

-
testissue2116\dubbo-kryo-server run TestServer to start dubbo-kryo-server service

-
testissue2116\dubbo-kryo-client run SimpleClient to call dubbo-kryo-server

Pls. provide [GitHub address] to reproduce this issue. [email protected]:llx206/testKryo.git
Expected Result
What do you expected from the above steps?
Actual Result
What is actually happen?
If there is an exception, please attach the exception trace:

Just put your stack trace here!
I found the problem to be the case when serializing using the kryo protocol. The above exception occurs when the service is both a provider and a consumer. Please help me to see it, thank you very much!
I can reproduce it by following the instructions above. I will look into it.
建议你还是升级dubbo吧,因为在2.6.1版本中,创建KryoObjectInput这个的Kryo对象会把SerializableClassRegistry里的registrations里采用的是Set集合来缓存类,全都注册进Kryo对象中,所以导致在DefaultClassResolver里的idToRegistration无法和客户端idToRegistration无法对齐。 在2.6.3里采用registrations用了Map<>来缓存类 了。
非常感谢,我试一下看看!
在 2018-09-05 02:10:57,"Muxin" [email protected] 写道:
建议你还是升级dubbo吧,因为在2.6.1版本中,创建KryoObjectInput这个的Kryo对象会把SerializableClassRegistry里的registrations里采用的是Set集合来缓存类,全都注册进Kryo对象中,所以导致在DefaultClassResolver里的idToRegistration无法和客户端idToRegistration无法对齐。 在2.6.3里采用registrations用了Map<>来缓存类 了。
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
@ZhuoSiChen ,升级到2.6.3后,使用kryo序列化协议,客户端调用还是会出现
,请帮忙看下吧,多谢!
@llx206 能否给个github 的demo我本地运行下。
@ZhuoSiChen ,gitHub地址:https://github.com/llx206/testKryo 操作步骤见最开始处:https://github.com/apache/incubator-dubbo/issues/2179#issue-347287850 大神帮忙看下是什么问题吧,非常感谢!!!
When serializing kryo in my project, the consumer call will also report an error. No provider available for the service com.lewanwuxian.service.AccountService:1.0 from registry 192.168.1.3:2181 on the consumer 192.168.1.29 using the dubbo version 2.6.3. Please check if the providers have been started and registered. My provider and consumer version of dubbo is 2.6.3.
- [ ] I have searched the issues of this repository and believe that this is not a duplicate.
- [ ] I have checked the FAQ of this repository and believe that this is not a duplicate.
Environment
- Dubbo version: 2.6.2
- Operating System version:Red Hat Enterprise Linux Server release 6.6 (Santiago)
- Java version: 1.8
Step to reproduce this issue
The execution method is as follows:
- mvn install all the project.
- testissue2116\summary-server run TestSummaryServer to start summary-server service
- testissue2116\dubbo-kryo-server run TestServer to start dubbo-kryo-server service
![]()
![]()
- testissue2116\dubbo-kryo-client run SimpleClient to call dubbo-kryo-server
Pls. provide [GitHub address] to reproduce this issue. [email protected]:llx206/testKryo.git
Expected Result
What do you expected from the above steps?
Actual Result
What is actually happen? If there is an exception, please attach the exception trace:
Just put your stack trace here!I found the problem to be the case when serializing using the kryo protocol. The above exception occurs when the service is both a provider and a consumer. Please help me to see it, thank you very much!
Well,It's not Dubbo's bug.It's a bug of how you use it.In your summary-server module,SummaryUser and SummaryPage has been registered as 55, 56.So in your dubbo-kryo-server module,SummaryUser and SummaryPage has been registered as 55, 56.But your dubbo-kryo-server module will regist User and Page as 57,58 when you use Userservice.And your dubbo-kryo-client just regist User and Page as 55,56.So you will get exception 'Encountered unregistered class ID: 57'.You just need regist SummaryUser and SummaryPage in your dubbo-kryo-client moudle. If you use kryo,you must ensure each jvm has same registered classes list.
Pls focus on https://github.com/apache/incubator-dubbo/issues/2881
@Bricks-Man This is a bug of dubbo. We provide a way for the registry class, so maintaining the relationship of the class id is what we have to do.
Pls focus on #2881
@Bricks-Man This is a bug of dubbo. We provide a way for the registry class, so maintaining the relationship of the class id is what we have to do.
OK.Thx