client.call_for return io_error #641
-
结构体参数传递和返回大小约100KB,独立线程ThreadFunc调用, 这个错误不是每次都出现,请帮忙分析下是否调用问题 async_simple::coro::Lazy show_rpc_call(inPara, outPara) try if (resD.error().code != coro_rpc::errc::ok) } } ThreadFunc() syncAwait(show_rpc_call(inPara, outPara); } |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
if (resD.error().code != coro_rpc::errc::ok) That is not correct. if rpc dont have error, call error() method is undefiend behavior(). See https://en.cppreference.com/w/cpp/utility/expected/error |
Beta Was this translation helpful? Give feedback.
-
You can check expected<T,E> by: if (resD/*or: resD.has_value()*/)
{
resD.value();
//it's OK
}
else {
resD.error();
// error happen
} OR: std::cout<<resD.value()<<std::endl; //throw expection if error happened. |
Beta Was this translation helpful? Give feedback.
-
你可以验证一下到底是真的有rpc错误,还是你在没有错误发生的时候去调用了error()方法。 |
Beta Was this translation helpful? Give feedback.
-
非常感谢,加上if (resD)条件后,没有失败和错误了。再请教一个问题,这个通讯安全性需要考虑吗,如 |
Beta Was this translation helpful? Give feedback.
-
这个就像http一样,你需要自己实现一些权限校验机制。比如要求用户在连接时先登陆,然后其他rpc函数检测当前是否有权限。 |
Beta Was this translation helpful? Give feedback.
-
此外,请注意,由于客户端处于不可信环境下,因此客户端的一切计算结果同样是不可信的,这点和http或其他rpc服务没有区别,服务端都应该对客户端的计算结果做校验。 |
Beta Was this translation helpful? Give feedback.
-
谢谢! 这个服务端有办法获取客户端的IP等信息吗 |
Beta Was this translation helpful? Give feedback.
if (resD.error().code != coro_rpc::errc::ok)
That is not correct. if rpc dont have error, call error() method is undefiend behavior(). See https://en.cppreference.com/w/cpp/utility/expected/error