The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

Any way to send large data via rpc's without it kicking us offline?

2019-01-14 13:28:08

We are trying to implement a level editor in our game, however instead of getting the users to download the maps via the workshop and restarting the game etc, we would like to try and send the level via an rpc.

The only problem is, some of the strings that the level editor produces can become 100,000 characters upwards quite rapidly and when we try to connect a second client to the room, when the rpc tries to get sent then the master client gets removed from the room and we recieve the following error:

"Cannot send messages when not connected. Either connect to Photon OR use offline mode!"

I assume its just a case of the string is way too long to be supported. We have tried numerous ways to try and get it to work including splitting the string up more than just sending it in one whole string, and also trying bytes.

I was wondering if anyone might have a way to get this to work, or if we would just be better using something like sockets or the workshop itself and getting users to download the maps on their own.

We are currently using Pun 1.X, just incase that changes anything.



2019-01-14 16:50:29

So, the level someone creates gets turned into a string? Do I get this right?

In general, strings are probably not really effective.
You might be able to minimize the data by using a binary format for your level.
Maybe you can apply compression (depends on what you get for the level).

Sending an RPC is also ineffective, as you have to send it multiple times (whenever someone joins), so it might make more sense to use a custom property or at least a buffered/cached event. Then the server will send the message, when someone joins.

In general, single messages have an upper limit of size and there is a send-buffer size restriction on the server, too. I will ping a colleague to help with the values.

2019-01-14 16:56:02

@Zek99 try to keep strings not bigger than 16K in bytes.

Also, you should keep in mind that if the entire message is bigger then 512Kb it will be discarded.


Back to top