Can't Encode Arguments in Remote Procedure Call for Server Registration

雨燕双飞 提交于 2019-12-10 15:44:26

问题


I'm going a bit crazy trying to figure out why this isn't working. I'm using sunrpc, but the generated server code throws the following:

Cannot register service: RPC: Can't encode arguments
unable to register (MYRPC, MYRPC_V1, udp).

I have no idea why this is happening. I'm doing the following to generate the stubs:

$ rpcgen -NMC myrpc.x

Here's my XDR

struct imgdata{
    opaque data<>;
};

program MYRPC {
    version MYRPC_V1 {
        imgdata minify(imgdata) = 1;
    } = 1;
} = 0x30D0D0DFF;

I don't get any errors compiling the .x file to create the client, server, xdr marshalling code, or the header. I've also implemented the rpc interface, but haven't been able to test it since that error is thrown the moment I attempt to spin up the generated server (myrpc_svr.c).

What arguments is this error message even referring? Does it not like my implementation of my function defined in the XDR? Why would an encoding argument cause the program to not even register?

I'm actually very surprised that this isn't a client side error message


回答1:


After hours of wasted time it turns out the answer was so simple: The Program Number is out of range.

program MYRPC {
    version     MYRPC_V1 {
        imgdata minify(imgdata) = 1;
    } = 1;
} = 0x30D0D0DFF;

My Program Number 0x30D0D0DFF contains an extra digit, F at the end causing this value to be out of range for allowed user-defined program numbers per the specification in section 7.3 of RFC 1831. It should have been:

0x30D0D0DF.

So this is just a subtle typo that I fat fingered while writing up the XDR file, but I'm leaving this up in case anyone else runs into the same problem. Make sure your program number is correct!



来源:https://stackoverflow.com/questions/29710501/cant-encode-arguments-in-remote-procedure-call-for-server-registration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!