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

call results in -32602 Invalid params when no params are given cause it sents null #151

Closed
basz opened this issue Nov 21, 2023 · 3 comments

Comments

@basz
Copy link
Contributor

basz commented Nov 21, 2023

Hello I'm integrating this library to connect to moonraker websockets. Now I find that moonrakers ws implementation is a little picky about null as params.

Sending a package as will work as expected.

{
    "jsonrpc": "2.0",
    "method": "server.info",
    "id": 2
}

however, this library will sent null if you do a call without params. Which for this method is what i need.

{
    "jsonrpc": "2.0",
    "method": "server.info",
    "params": null,
    "id": 2
}

Which result in a

{"code": -32602, "message": "Invalid params:"}

I verified params: null is the issue as i changed this line to return undefined (meaning it will not get sent)

var message = {
          jsonrpc: "2.0",
          method: method,
          params: params || null,
          id: rpc_id
        };

Now my question. Can we change the null to undefined?

As it stands tis lib is not compatible with moonraker rpc json.

ps. I also try to sent [] or {} as params.

@mkozjak
Copy link
Member

mkozjak commented Nov 21, 2023

Yes, based on the specification, the params key could be omitted. I'll see about implementing this.

@basz
Copy link
Contributor Author

basz commented Nov 22, 2023

I can do a PR if you want

@mkozjak
Copy link
Member

mkozjak commented Nov 22, 2023

Fixed in #152

@mkozjak mkozjak closed this as completed Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants