I want to give points to a number of users who have participated in an event every so often and record them in their profiles.
The number of these users is about 30 thousand.
This process takes about 4 minutes.
If I call the method directly when starting the server, everything works fine.
But if I call it with an RPC from outside, the method stops after a few seconds because it does not belong to a large number of users!
What is my problem?
Is there a timeout?
If yes, tell me how to solve the problem.
I want to call the method with RPC.
Hello @rhs3322,
If the request takes that long it should be timing out which is leading to the query being cancelled, try setting the timeout of the RPC request to a value that is long enough for the process to finish.
Best.
Can you tell me exactly how to configure the timeout of the RPC request?
This is something that is set in the HTTP client, how are you invoking the RPC?
try { fetch("https://myIP:Port/v2/rpc/setScoreRpc?http_key=myKey&unwrap", { method: "post", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ min: 1, max: 2 }) }).then((response) => response.text()).then((result) => console.log(result)).catch((error) => console.error(error)); } catch { }
Depending on where from you’re using fetch
(Node.js, browser or other implementation) you’ll need to look into how to set the request timeout, sadly I’m not familiar enough with fetch
to indicate the correct way of doing it, maybe someone else in the community may help further.
I only need to use RPC to run cron jobs on the system.
Does Nakama have a built-in method to run scheduled tasks?
If there is a built-in method, I will not have to use this RPC anymore.
Hello rhs3322,
For cron jobs, it’s best to use the system’s built-in scheduling tools (e.g., Task Scheduler on Windows or crontab on Linux) instead of relying on client calls.
Exposing a cron job via RPC is risky without proper authentication and validation, as it can lead to misuse, system overload, or security vulnerabilities.
If necessary, you could set up a local cron job to call the RPC at specified intervals and secure it with a reverse proxy like NGINX, blocking external access to ensure it is only used internally.
Alternatively, depending on your use case, a just-in-time (JIT) approach as outlined here may be more suitable.