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

Unparseable message: "ping" #1319

Open
slyons opened this issue Mar 11, 2024 · 3 comments
Open

Unparseable message: "ping" #1319

slyons opened this issue Mar 11, 2024 · 3 comments

Comments

@slyons
Copy link

slyons commented Mar 11, 2024

I'm working with an API that seems to be doing things a bit backwards. Instead of the client sending the "ping" messages, it's the server, expecting the client to respond with the appropriate "pong", leading to the following error:

Error: RestartNeeded(Custom("Unparseable message: {\"method\":\"ping\",\"params\":null}"))

Barring rewriting the ping functionality to work in reverse, is there any way of handling unparseable messages?

@niklasad1
Copy link
Member

niklasad1 commented Mar 11, 2024

Barring rewriting the ping functionality to work in reverse, is there any way of handling unparseable messages?

Unfortunately, no we just terminate the connection once that occurs.

The issue is not that the server is sends "pings" as JSON-RPC notifications but that the field jsonrpc is missing from the notification which is not according the spec

jsonrpc
A String specifying the version of the JSON-RPC protocol. MUST be exactly "2.0".

FWIW, it's really a weird implementation for a WebSocket server to send pings as JSON-RPC notifications which are not possible to answer/ACK. The reasonable thing is to use native WebSocket pings/pongs as jsonrpsee is doing.

I guess we could ignore those messages but a long time ago we decided to be explicit and terminate the connection when an error occurs.

/cc @lexnv @jsdw thoughts?

@slyons
Copy link
Author

slyons commented Mar 12, 2024 via email

@jsdw
Copy link
Collaborator

jsdw commented Mar 12, 2024

If it wasn't too tricky to do, I'd have no objection to being able to set some handler that's called with any such messages and returns a boolean or whatever to determine whether to ignore it or stop (and then the default could be to stop).

In the future, if the client was to (optionally) return a "driver" thing that you need to poll to make progress, then I'd imagine that such errors would be emitted by the driver and then you'd have the chance to decide whether to ignore them or stop or whatever.

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

3 participants