Search code examples
crpcxdrsunrpc

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


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


Solution

  • 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!