# RPC method stopped

**URL:** <https://forum.heroiclabs.com/t/rpc-method-stopped/5833>\
**Category:** Runtime Framework\
**Tags:** typescript\
**Created:** [November 26, 2024, 4:00pm UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833 "2024-11-26T16:00:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhs3322](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rhs3322/32/2306_2.png) [@rhs3322](https://forum.heroiclabs.com/u/rhs3322)\
**Post date:** [November 26, 2024, 4:00pm UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/1 "2024-11-26T16:00:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 26, 2024, 4:09pm UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/2 "2024-11-26T16:09:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rhs3322](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rhs3322/32/2306_2.png) [@rhs3322](https://forum.heroiclabs.com/u/rhs3322)\
**Post date:** [November 27, 2024, 4:41am UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/3 "2024-11-27T04:41:47Z")

</div>

> [@sesposito](#):
>
> q

Can you tell me exactly how to configure the timeout of the RPC request?

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 27, 2024, 11:11am UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/4 "2024-11-27T11:11:25Z")

</div>

This is something that is set in the HTTP client, how are you invoking the RPC?

---

<div class="post-metadata">

**Author:** ![rhs3322](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rhs3322/32/2306_2.png) [@rhs3322](https://forum.heroiclabs.com/u/rhs3322)\
**Post date:** [November 27, 2024, 11:54am UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/5 "2024-11-27T11:54:09Z")

</div>

```
 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 { }

```

---

<div class="post-metadata">

**Author:** ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)\
**Post date:** [November 27, 2024, 12:12pm UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/6 "2024-11-27T12:12:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rhs3322](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rhs3322/32/2306_2.png) [@rhs3322](https://forum.heroiclabs.com/u/rhs3322)\
**Post date:** [November 27, 2024, 3:16pm UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/7 "2024-11-27T15:16:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rephlex187](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/rephlex187/32/2377_2.png) [@rephlex187](https://forum.heroiclabs.com/u/rephlex187)\
**Post date:** [November 30, 2024, 8:51am UTC](https://forum.heroiclabs.com/t/rpc-method-stopped/5833/8 "2024-11-30T08:51:14Z")

</div>

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](https://heroiclabs.com/docs/nakama/guides/server-framework/background-jobs/) may be more suitable.
