Triggering Client Events With Large Arguments

Is there a limit on the size of your args when triggering a client event from the server, or is there a known issue of client events not being triggered when the args exceed a certain size?

We’ve recently encountered an issue on our server where triggering a specific client event from the server does not reach some clients (the functions in the client event don’t run, and the event does not appear in the network event log). Again, this only occurs for certain clients, while others successfully receive the event. The event is triggered after a client loads their character and not via a -1 to all clients at the same time.

The size of the arguments sent in the event is approximately 5MB. Initially, we thought the payload might be too large, so we triggered the event without the large payload, which resulted in all clients successfully receiving the event. We then attempted to send the 5MB payload using TriggerLatentClientEvent at 1,000,000 bps, which also resulted in all clients successfully receiving the event.

Given that both triggering the event without the large payload and using a latent event worked, we assumed the payload size was the issue. However, I’m unsure why the event triggered for some clients but not others with the large payload. Is there a limit on the size of an event payload where it becomes unreliable? Or, if the client has a poor connection, could this result in events with large payloads consistently not being received by the client?

1 Like

You’ve got me super curious, what are you sending that needs to be so large?

1 Like

It’s a table that contains house data for over 490 houses. Each house entry contains all the furniture models and their positions so that the furniture loads when the player enters the property. We have a fair number houses that have over 500+ pieces of furniture in each house which is why it’s so large. The script was really only built with a small player base in mind.

Ideally it would be best to only send the furniture data when the player enters the property instead of for all 490+ houses at once when they load in.

This.

Your current solution has only negative side effects:

  • Puts extra strain on the network
  • Depending on connection speed and hardware can cause lag on player systems when receiving
  • As you said yourself: Sometimes there is no data received at all.

I would not know of such a limit, but from previous experience I can say that sending large amounts of data can cause substantial lag (long freeze frame) on the target client. I remember we had up to 500ms freezes on our server as we were doing something similar (sending data for all owned vehicles to clients (crude calculation 4MB of data))… Though that was like 6-7 years ago. Not sure how much events have changed performance wise since then.

3 Likes

I would think it has to do with latency. From what I remember from the trigger Latent Client event documentation, clients and servers can freeze if they’re receiving too much data and can timeout.

Edit: Confirmed -

This is important for timeout functionality, as sending a large amount of data blocks the network for the client, and if blocked for too long, will result in the client timing out.

Source:
https://docs.fivem.net/docs/scripting-manual/working-with-events/triggering-events/#triggering-latent-client-events

I’m guessing it’s a combination of either the latency, or any ALTERNATIVE events that the clients are triggering which could be queueing up and causing timeouts.

My suggestion for testing is to trigger the event on n number of clients that aren’t executing any other events or making any client-server transactions.

Also, if you have enough players, make note of their geolocation and you may find patterns there as well!

The only thing this leaves is if event-throttling leaves any trace on the logs. Would be a helpful distinction for moments like this…

1 Like

Thanks for your reply!

Interestingly, I’ve now noticed this issue with other events on the server as well. If the payload exceeds approximately 5MB, it will not reach clients running the latest (unstable) client build. However, when clients switch to the release or beta builds, they can receive events with payloads exceeding 5MB.

2 Likes

I’ve noticed a bunch of “TriggerLatentClientEvent” warning in my server console lately, but I can guarantee the scripts its warning for are not directly calling that native. I’ve been led to believe CFX has some internal logic for making large payload events latent by default. We had to enable setr sv_enableNetEventReassembly true in the cfg for the warning to go away.

2 Likes