Ping -1 problem on some Android devices (Cannot send to: Access denied )

Hello everyone,

I'm going to release a soccer game using photon realtime. Unlike Photon PUN, Real-Time does not have best region option for master server. Thus I had to implement my ping solution. What I did is simply get a master server list and then send pings all the servers to find the best connection. It works well mostly but on some Android devices ping time always -1 for all regional servers. What does cause this problem? is there a better way to do it?

I got this error from crashlytics. Some devices never connect because of this;
"Cannot send to: Access denied "


  • Hi @SSahin,

    Thank you for choosing Photon and sorry we have missed your other question before.

    You use TCP? did you try UDP also?
    "Cannot send to: Access denied "

    Could you give us complete details from crashlytics, like stacktrace?
    Try getting more info from crashlytics to narrow down the issue, like if this is related to an ISP/country...

    So you are saying some Android devices cannot ping the region servers because they have this error.
    So those clients never get the list of the region servers to ping.
    So I'm guessing they manage to connect to the nameserver ( and fail to send GetRegions request command? Or they even fail to connect to nameserver?

    how do you ping the servers? do you use the normal ICMP ping or you follow how PUN/PUN2 do it?
    could you share the code?
  • SSahin
    edited October 2018
    Hello John,

    Here is Dropbox link

    the zip file contains crashlytics logs, device details, ConnectionOrganizer the class I used.

    I used unity's ping class. After connecting nameserver It gets region addresses, then ping to those servers always return -1 time. It's not relevant to OS version or Location as I understand. Probably problem inside code or unity.

    Unity version: 2017.4.10f1
  • JohnTube
    JohnTube mod
    edited October 2018
    then ping to those servers always return -1 time.

    I thought maybe you managed to do this successfully at least once.

    I see as I suspected please switch to Photon Ping and not Unity's ping (it does not work all the time for all platforms) as we use a special UDP based ping.
    Just copy paste and adapt code from PUN.

    an old discussion I started for reference.
  • Thanks, John

    I downloaded Pun2, there is a class called "RegionPinger" is it enough for just sending pings?
  • JohnTube
    JohnTube mod
    edited October 2018
    well, surprise surprise, you can use Photon Realtime 2 (the new LoadBalancing API not released standalone yet) from PUN2 and it has the feature you are looking for :smile:
    Just remove "Photon/PhotonUnityNetworking" and "Photon/Chat" as you do not need them and adapt your code.
  • SSahin
    edited October 2018
    oops, I just finished implementation,
    what I did is copying RegionHandler and Region classes from PUN 2. And it seems working. Should I change it? I mean is it better the new version?
  • no, you can keep your code as is if it works.
    I just remembered how easy it is to extract Photon Realtime 2 from PUN2.
  • Hmm, new API is broke the old one, I cannot update the old one now. Any way I copied the RegionHandler and Region classes from PUN 2 and it worked.