Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method Not Found when making an RPC call #102

Open
vssalcedo opened this issue Apr 5, 2021 · 0 comments
Open

Method Not Found when making an RPC call #102

vssalcedo opened this issue Apr 5, 2021 · 0 comments

Comments

@vssalcedo
Copy link

Hi there.

I'm setting up a public server to test an RPC call from anywhere, but when it comes to call an RPC function it returns:
{ code: -32601, message: 'Method not found' }

It's pretty weird because I tested the rpc method with wscat like so:

  1. Connected to the rpc server with: wscat --connect ws://localhost:8082
  2. Once connected, I used this cmd to call the 'test' method.
    {"jsonrpc": "2.0", "method": "/test", "params": null, "id": 1}
    and as you can see in the following image, it returns as expected:

image

But when I try to call the same method with rpc-websockets client library it just returns { code: -32601, message: 'Method not found' }

This is my current setup on both client and server:

Client

RPC.on('open', async function() {

    console.log("Client connected [OK]");

    const meths = await RPC.listMethods();

    console.log(meths);

    try {
        const result = await RPC.call('/test', null);

        console.log(result);
    }
    catch(err) {
        console.log(err);
    }
});

RPC.on('error', function(err) {
    console.log(err);
});

And this is the Output that I get from my terminal on Client:

image

As you can see, I make a call to listMethods, but no methods are registered, so IDK why that happens. But I'm able to perform a call to the method itself with wscat tool.

Server

const WebSocketServer = require('rpc-websockets').Server;

const rpc = new WebSocketServer({
  port: '8082',
  host: 'localhost'
});

rpc.register('/test', params => {
    console.log("Test RPC [OK]");
    console.log(params);

    return 'OK RET';
});

I'm really stuck with this issue and I'm not able to resolve it.
It would be great if you could help me to figure out what's going on.
I'll really appreciate it. Thank you very much in advance.

@elpheria elpheria deleted a comment from trasherdk Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant