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

Fix error message when sent HTTP GET to RPC #4314

Merged

Conversation

chenyukang
Copy link
Collaborator

What problem does this PR solve?

After RPC framework changed, if we sent an GET request to RPC endpoint, the error message has changed to:

Missing request extension: Extension of type `jsonrpc_utils::stream::StreamServerConfig` was not found. Perhaps you forgot to add it? See `axum::Extension`.%

Let's keep the same message with the old version.

Issue Number: close #4309

Problem Summary:

What is changed and how it works?

Add a special handler for RPC endpoint, distinguished from the Websockets configuration.

What's Changed:

Related changes

  • PR to update owner/repo:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code ci-runs-only: [ quick_checks,linters ]

Side effects

  • Performance regression
  • Breaking backward compatibility

Release note

Title Only: Include only the PR title in the release note.

@chenyukang chenyukang requested a review from a team as a code owner January 20, 2024 10:02
@chenyukang chenyukang requested review from quake and removed request for a team January 20, 2024 10:02
post(handle_jsonrpc::<Option<Session>>).get(handle_jsonrpc_ws::<Option<Session>>);
let post_router = post(handle_jsonrpc::<Option<Session>>);
let get_router = if enable_websocket {
get(handle_jsonrpc_ws::<Option<Session>>)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If enable_websocket is set to true, will the client side receive the error message Used HTTP Method is not allowed. POST or OPTIONS is required when sending a GET HTTP request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's only for HTTP endpoint.
but the error message for Websocket still have a difference, for request like this send to port 28114 (Websocket port):

curl -s -X GET http://127.0.0.1:28114  -H 'Content-Type: application/json' -d '{ "id": 42,   "jsonrpc": "2.0", "method": "get_raw_tx_pool", "params": [] }

the old:

WebSocket Protocol Error: Unable to parse WebSocket key.%

now:

Connection header did not include 'upgrade'%

I think it's not necessary to fix it.

eval-exec
eval-exec previously approved these changes Jan 20, 2024
@chenyukang
Copy link
Collaborator Author

Another weird special issue, maybe we need to compatible with old version,

send request to ping, it will always return pong as health checkpoint.

curl -s -X GET http://127.0.0.1:8114/ping  -H 'Content-Type: application/json' -d '{ "id": 42,   "jsonrpc": "2.0", "method": "get_raw_tx_pool", "params": [] }'
pong%

I add another commit to make new RPC works as before, @eval-exec please re-approve.

@quake quake added this pull request to the merge queue Jan 25, 2024
Merged via the queue into nervosnetwork:develop with commit a3617dd Jan 25, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants