Sending a byte array 16times per second, disconnect

Hi, I'm trying to send a byte array that has a length of 75 about 16 times per second for a few seconds at a time. I've tried doing this with a serialized stream and also through RPC calls, but if I send more than about 10 times per second, it disconnects the player really quickly. Is there a stable way for me to send this? I'm not sure if I'm hitting some byte limit or something because it's definitely not going over the message limit.


  • Hi rstorm000,

    sending a byte-array of that size about that often shouldn't be a problem. In a small test I did, I was able to do even more. May be you 'forget' to call service() in a certain situation?

    It would help me if you post some more information about your setup. There surely isn't a limit this low.

    Tell us what solved your problem, if you got it ;)

  • If you didn't already, update to the latest PUN version. We always find something to improve and any bug avoided this ways is a good one.
    Our servers are in Europe. If you connect to them from America or Asia, this might be a problem. We have servers there, too. Just let us know where you are.
  • Just checked this out again, looks like the byte array length is actually 320 not 75. Should this be a problem? So it calls an RPC 16 times a second that sends this byte array. Which should equate to 320*16 = 5000bytes per second going up. I can reduce this to 128*16 as well for 2048bytes per second up.

    I'm sending voice/sound data from the new Voice Chat product in the asset store. The audio does arrive when I've done this with RPCs or streams, but has been disconnecting after using it for more than a few seconds.

    after compressing the voice data I just call this 16 times per second (invoke repeating):
    photonView.RPC("SendVoiceChat", PhotonTargets.Others, packet.Data);
  • Is the data a byte-array of length 320 (or 128)?
    What else are you sending (is a game going on, etc)?

    I think the default "send rate" settings for PUN might be suboptimal for this case. You could try increase it by setting the PhotonNetwork.sendRate. Don't mix it up with the sendRateOnSerialize, which defines how often PhotonViews are called to package updates of their observed object / script.

    Are you using the latest PUN version?
  • the byte array can be 320, 640, 128 or however long (but it stays consistent) based on the compression/sample rate settings for the voice input. If using RPCs, should I change the PhotonNetwork.sendRate to higher. Currently I've been working with
    PhotonNetwork.sendRate = 30;
    PhotonNetwork.sendRateOnSerialize = 15;

    Should I go higher?

    Also, yes I do have the latest version of PUN, I just made sure again, by reimporting yesterday.
  • A sendrate of 30 should be ok for 16 RPCs plus some other stuff.
    Which Roundtrip Times (ping) does the PhotonNetwork give you?

    You could add the PhotonStatsGui to your scene and have a look at the messges and bytes /sec.
  • I'm getting ping around 50 to 95ms. I have been looking at the stats GUI and it does seem to match the numbers calculated when voice is sending
  • But you still have disconnects?
  • it disconnects on all but the smallest compression settings, which is a byte array with 128 length. Also its seemingly always the person sending that gets disconnected. Not sure how often with receiving, but I think I saw it once or twice. What's the byte limit we're looking at here? Would upgrading from indie account to 500 messages help?
  • I can assure you it's not the subscription CCU or message limit.

    I can try to reproduce the issue but I'm not sure if I run into the same situations. Could you share your project with us? If so, send us a download link or asset server info to [email protected]

    You could include the PhotonStatsGui to your project and have a look at the timings it shows. The "longest delta between" values are interesting. Are they ever bigger than 1000ms?
  • I think perhaps it was the connection at the location I was at. I have been testing out this at more locations now, and all of the other ones have worked perfectly even with the higher byte sizes of 640 in the array. So far with no disconnections.

    The project is here.

    It might be awesome for you guys to look into or contact the creator since voice chat is one of the things people have been looking for most in any online solution. I'm not sure, but perhaps there is a way to integrate or optimize it even more for Photon specifically. I have been testing it only with a couple people, but will be continuing to see how it functions with many players simultaneously.

    Also as a side note, the new version of photon released a couple days ago pulls some errors before compilation about access of certain variables in the PhotonNetwork class as well as problems with a "partial class" in one of the new files I believe. I got it to work fine, but I had to change some class names.
  • The errors and warnings would be interesting. I didn't notice those but if there are some, we'll fix of course.
    Otherwise it works ok for you now?! Great to read.
  • try sending rpc as unreliable one :)