PRC编程 常见问题
RPC编程常常会碰到各种问题,尤其对于刚接触和使用RPC的开发人员而言,有些简单的问题却很难通过GDB等常规手段定位。因此,这篇博文归纳了RPC开发过程中常见的一些问题和解决办法,以便自己今后参考。当然,随着对RPC的更多接触,会碰到更多的问题,将会在后面陆续整理到一起。
1. RPC: Unable to receive 错误
现象如下:
[root@localhost bin]# ./test_rpc
probe_nvm_ops: Fail to detect (simulated) nvm by cmds lsmod | grep "arxcis"!
probe_nvm_ops: Fail to detect (simulated) nvm by cmds lsmod | grep "gigaram"!
probe_nvm_ops: Success to detect (simulated) nvm by cmds cat /proc/cmdline | grep "mem"!
nvm status on 127.0.0.1: OK
nvm status on 10.0.0.110: OK
10.0.0.111: RPC: Port mapper failure - RPC: Unable to receive
解决办法Solution:重启(启动)rpc服务
systemctl start rpcbind.service
2. RPC: Unable to send 错误
错误现象如下:
RPC: Port mapper failure - RPC: Unable to send
解决办法:
检查本地的IP 是否设置正确,它必须存在,且必须和注册RPC时使用的IP一致。
3. Program not registered错误
现象如下:
[root@localhost bin]# ./test_rpc
probe_nvm_ops: Fail to detect (simulated) nvm by cmds lsmod | grep "arxcis"!
probe_nvm_ops: Fail to detect (simulated) nvm by cmds lsmod | grep "gigaram"!
probe_nvm_ops: Success to detect (simulated) nvm by cmds cat /proc/cmdline | grep "mem"!
nvm status on 127.0.0.1: OK
nvm status on 10.0.0.110: OK
10.0.0.111: RPC: Program not registered
解决办法Solution: start a thread or daemon to rigeister RPC in remote node
4. 对于复杂的数据结构没有生成XDR线程
这个时候需要用rpcgen -c *.c 来自动生成XDR线程,或者.x文件格式错误、版本冲突。
当然了,实际开发过程中碰到的问题可能千奇百怪,RPC开发过程中碰到的问题需要结合错误信息、基于RPC底层机制,有时还需要参考自动生成的参考代码,才能高效的定位和解决问题。