-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
graphql: add query timeout to prevent dos attack #26116
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I wonder if 60s isn't a bit too lenient.
We use graphql queries to fetch block and transaction data in bulk. The range of blocks we are able to fetch is between 100-1000. But the response time varies on the data size. Would it be possible to make this configurable ? |
If the number of connections are not creating any problems, instead of making it configurable and failing fast, setting the limit according to max range would work fine imo. |
Is it possible make this configurable/ add a start parameter? like geth --querytimeout=2000ms |
Scaling the timeout with request size is not possible in the general case. It's also not what this timeout is for. We mainly want to prevent totally stuck queries with this timeout, so it can be long. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Error example:
{
"errors": [
{
"message": "context deadline exceeded"
}
]
}
Actually this also interacts with the RPC WriteTimeout. The error I posted above will never be returned to the user because connection will be severed at the 30 seconds mark (See #21430 and #25457). I still don't think there's a harm in adding a timeout to graphql, but the original issue was actually a non-issue and the timeout set here is too long. |
So something between 20-30 sec should be good? @s1na |
@ahmetavc Yes let's shoot for a bit under 30 sec. |
Wait, so we apply the RPC WriteTimeout to GraphQL connections as well? |
This PR adds a 60 second timeout to graphql queries.
Question regarding the timeout: Can I disable this? I'm running large queries and get error messages like this:
I tried several approaches with requests, httpx to talk to the graphql on geth. Ideally you'd want to run a setup with a proper firewall config, and nginx or another webserver handling and limiting the traffic and timeouts for connections instead of exposing geth RPC / WSS directly to the internet. Hoping there's a parameter, read a through the issues here and the docs. Can't really figure out how to disable this. |
@Doc-Pixel Please try adding the following to your
|
Thank you! |
#26026 as its proposed in this issue, I added the timeout