High latency issue android NDK (Loadbalancing sample)

Options

I am sending custom events reliably using LoadBancing example but some time the events are taking to long to delivered at the other client,
How do i improve the latency ?

please help

Comments

  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    Are you using Photon Cloud or Photon Server? If it is the former one, then the first step would be to check which region the client is connecting to.
    If for example the client runs in Eastern Asia, but connects to the default server region, which is hosted in Western Europe, that will guarantee suboptimal latencies.

    Also please make sure that you call service() often enough. opRaiseEvent() (and other operations) only put the messages into the outgoing queue, but they are not actually sent until the next service call.

    So, when you are calling service every 100ms, that would on average add 50ms additional latency, until the message already gets sent, and another additional on average 50ms, until you get the response.
  • Harish_Kagale
    Options
    Hi ,Kaiserludi

    i'm using Photon Server with default address "ns.exitgames.com" client runs in south asia
    and is selecting region "eu"
    can this be a problem ?

    or

    I'm calling service() and rasing events at every 50ms
  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    i'm using Photon Server
    You mean Photon Cloud.

    Photon Server is the variant, where you are hosting the server yourself.


    Please set your region explicitly to "asia" and check if that helps.

    I have described how one can explicitly set the region at
    http://forum.photonengine.com/discussion/comment/24981#Comment_24981


    When applying the steps from that post please be aware that since version 4.1.3.0 the bool parameter 'useDefaultRegion' of the constructor of class Client got replaced with an nByte parameter 'regionSelectionMode' to which one must pass one of the values of the RegionSelectionMode enum.
  • Harish_Kagale
    edited June 2016
    Options
    Hi ,Kaiserludi

    After setting the region exlicitly to asia its working good, but every time i cant set the region to Asia as client does not run always in Asia. it can be in other regions

    Is there any way to set the region through native code at run time as per its current location ?

    There is another problem some time i am getting the connection error with error code 1040 ?
    what does this error code mean ?
    and it takes time to notify other client which is joined within the same room.
  • Kaiserludi
    Options
    Hi @Harish_Kagale.

    You could either use OS functionality to retrieve the country that settings of the device and implement a switch that selects a certain region depending on those country settings.
    For example if the country setting would be Germany, then you would choose the EU region.

    Another option is to use the new bestRegion feature, that has recently been introduced with the 4.1.3.0 release.
    Therefor you would check, if you have already stored a best region on the hard disk. If that is the case, then you would choose RegionSelectionMode::SELECT and select that region, but when that is not the case, then you would instead choose RegionSelectionMode::BEST, which makes the Photon Client ping all available regions and select the best one for you. After you got connected you would then retrieve the chosen region by a call to Client::getRegionWithBestPing() and store the retrieved region code on disk.
    Storing the region locally on the device instead of each time using RegionSelectionMode::BEST is recommended because it avoids that the client needs to send out pings to all regions on every connect. Pinging takes a moment, as several ping signals (currently hardcoded to 5 pings per region) need to get sent to servers of which some are at the other end of the world.

    1040 is the code for a client side timeout disconnect.
    You can look up those codes at Photon-cpp/inc/Enums/StatusCode.h.
    You get that code when the client can't reach the server anymore for some time (the default value is 10 seconds, but you can change this value through a call to Client::setDisconnectTimeout()).
    It is normal that it takes some time until remote clients recognize that a client is disconnected, because they can't know that before the server side disconnect for that client has triggered (which will happen 5-10 seconds after the server received the last life-sign from that client). At that time the server informs the other clients that are inside the same room.
  • juaxix
    juaxix ✭✭
    Options
    How did you manage to compile the Android project?, I'm having problems to do so, but Windows SDK, no problem.