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

jsonrpc implementation upgraded to support more features #3900

Closed
zhangsoledad opened this issue Mar 22, 2023 · 3 comments · Fixed by #4170
Closed

jsonrpc implementation upgraded to support more features #3900

zhangsoledad opened this issue Mar 22, 2023 · 3 comments · Fixed by #4170
Assignees

Comments

@zhangsoledad
Copy link
Member

zhangsoledad commented Mar 22, 2023

#3880

The currently used jsonrpc implementation does not support configurations such as client body read timeout, researching new options, an optional alternate is jsonrpsee, but it lacks tcp mode, or via jsonrpc-utils to build a new framework

@zhangsoledad zhangsoledad converted this from a draft issue Mar 22, 2023
@eval-exec eval-exec moved this from 🆕 New to 🏗 In progress in CKB Kanban Apr 6, 2023
@chenyukang
Copy link
Collaborator

chenyukang commented Apr 17, 2023

Seems jsonrpc is not designed well, the function process_body can not be put in async with a timeout, since it's in a poll of a future:

https://github.com/paritytech/jsonrpc/blob/master/http/src/handler.rs#L255

Anyway, jsonrpc is not maintained now, and we'd better move to jsonrpsee, but some APIs
are also changed.

@zhangsoledad
Copy link
Member Author

@chenyukang We can't use jsonrpsee directly, as already mentioned above, it doesn't provide tcp support

@chenyukang
Copy link
Collaborator

We could use jsonrpc-utils to add timeout for request:

The code sample:

https://github.com/sopium/jsonrpc-utils/compare/master...chenyukang:jsonrpc-utils:yukang-add-timeout?expand=1

Testing with:

curl --location 'http://127.0.0.1:3000/rpc' \
-H 'content-length: 100' \
--header 'Content-Type: application/json' \
--data-raw '   {
        "id": 42,
        "jsonrpc": "2.0",
        "method": "@ping",
        "params": [
        ]
   }'

Output should be:

Request took too long

@chenyukang chenyukang self-assigned this Sep 25, 2023
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in CKB Kanban Dec 12, 2023
@EthanYuan EthanYuan moved this from ✅ Done to 🥳 Released in CKB Kanban Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants