Connection with error code 1040

HI

Trying to connect to photon server using 2g mobile network but getting connection error with error code 1040
on each connect ,
we want to make it work on tg network too.
please help

Comments

  • Hi @Harish_Kagale.

    It should work just fine with 2G.
    What comes to my mind is that you may try to push through too much data in too short of a time compared to what a 2G network can handle.

    You might want to send less updates on such a slow network.

    If you are developing on iOS you might want to use the iOS network conditioner, that Apple ships as part of iOS, to artificially simulate a bad network. That way you could easier debug how your app behaves in this situation.

    1040 is a client side timeout disconnect. This means that the client does not get acks from the server in time fore the reliable data that it sent out, which may be due to the slow network not allowing all sent data to get out quickly enough.

    Is this happening already before you even get the connect callback?

    Could you please increase the logging level and show me the Photon Clients log output?
  • yes it is coming with the connect api itself i am not even sending data,

    i am just calling connect api in connectionreturn callback i am getting this error code
  • So could you provide me a log file, please?

    Can you reproduce this with a demo?
    Is this happening with a live app?
    Does this still happen, when you switch appVersion, so that you can't see any other players?
    Does it help if you set autoJoinLobby to false?
  • Harish_Kagale
    edited July 2016
    which log file your are asking about? Actuly i only get the error in my logcat stating the error code in connectionReturn callback
    yes its happening with demo app as well as with our app
    No app version is still 1.0

    i have not checked what response i'll get by setting autoJoinLobby to false
    but i want the client to join lobby as soon as the client gets connected to server as i want the list of rooms after the initial connect
  • demo_loadBalancing is calling mLoadBalancingClient.setDebugOutputLevel in the consturctor of class NetworkLogic. This setting controls how much the Photon client is logging.
    The Photon client send its logs to Listener::debugReturn(). The demo implementation of that callback prints the log to stderr, but your app may log it elsewhere (for example send it to a txt or a database, a server, etc.) if you prefer that.
    I would like you to set the debug level to DebugLevel::ALL,then reproduce the issue with demo_loadBalancing and show me the Photon client log output.

    The Android implementation for forwarding the log to logcat in the demo is in AndroidNetworkLogic.cpp.
  • The point why I have asked you what happens when you set autoJoingLooby to false, is, that we then would know, if the issue is somehow related to joining the lobby.
    Turning off lobby joining is not intended to be a "solution", but just a way to narrow down the source of the problem.
  • hi
    i tried by setting the auto joinLobby to false but same response


    following is the log that i am getting



    07-22 10:53:55.346: I/Photon Demo(12348): 2016-07-22 10:53:55,363819 INFO PeerBase.cpp connect() line: 175 - address: ns.exitgames.com:5058
    07-22 10:54:06.766: I/Photon Demo(12348): 2016-07-22 10:54:06,778611 INFO EnetPeer.cpp sendOutgoingCommands() line: 172 - disconnect due to retry timeout (max retry time) time: 11414 originalSentTime: 1410
    07-22 10:54:06.766: E/Photon Demo(12348): 2016-07-22 10:54:06,778832 ERROR NetworkLogic.cpp connectionErrorReturn() line: 490 - code: 1040
    07-22 10:54:06.786: W/ResourceType(12348): Failure getting entry for 0x01080940 (t=7 e=2368) (error -75)
    07-22 10:54:06.816: I/Photon Demo(12348): 2016-07-22 10:54:06,829609 INFO NetworkLogic.cpp disconnectReturn() line: 624 -
  • Harish_Kagale
    edited July 2016
    solved the issue by increasing the Disconnect timeout to 60000ms ,
    but the problem now i am getting is when the cilent gets disconnected from the server it is not giving me the call back as soon as it is disconnected it takes time because of which we are getting the synch issues in multiple clients.

    To solve this synch issue i want to check whether the client is connected to server or not after some time intervals how do i do it ?

    I have another question not releated to above issue , can we send nbyte[] as event
    if yes how do i do it ? , i mean how do i convert jstring to nbyte[] and vice -versa
  • Harish_Kagale
    edited July 2016
    can we send nbyte[] as event
    if yes how do i do it ? , i mean how do i convert jstring to nbyte[] and vice -versa

    currently i am sending a large Java string i want to optimise the data transfer how do i do it ?
  • Hi @Harish_Kagale.

    Well, Photon does automatically check, if a client is still connected and times it out, if it does not respond before the disconnect timeout kicks in. If you are increasing the disconnect timeout to 60 seconds, that naturally means that it will take 60 seconds until other clients know that this client is disconnected.
    Of course you could just send an opRaiseEvent() to a particular client once every x seconds and consider a client disconnected that does not send such a event for y seconds.

    Another idea that comes to my mind is setting the disconnect timeout high on connect and reducing it to a much lower value again after the client established the connection, so that you workaround for that 2G connection issue is still intact, but clients that got disconnected later on inside a game would be detected quicker.

    A string can be sent this way:
    opRaiseEvent(reliabilityFlag, myString, eventCode);

    To send an array you need to supply the arraySize right after the array itself:
    opRaiseEvent(reliabilityFlag, myArray, myArraySize, eventCode);

    Well, what is the format in which you have the string?
    If it is not a char* already, then first bring into into UTF8 char* format.
    For a JString this can be done like this:
    char* cStr = myString.UTF8Representation().cstr();
    Afterwards just cast the char* to a byte-array:
    nByte* myArray = (char*)cStr;
    int myArraySize = strlen(cStr);

    However I don't see how this would in any way optimize the size of the data.
    You would need to process the array with some kind of compression algorithm for that.

    Probably it makes more sense to rethink if you really need to send such a long string, or if you could rather find a way to omit sending some parts of it altogether.
  • HI ,Kaiserludi
    Actuly i am getting high latency between events i want to reduce the latency , so i just wanted to know
    is there any way to reduce the latency because the game on which i am working is actuly a realtime multiplayer so i cant afford latency more than 1 sec. so could you please guide me to reduce the latency by any way that would be great.


    and for Time out if i cahnge the diconnect time out after the connection will it be okay ?
    or is there any other way to know the client is disconnected from photon


  • Kaiserludi
    Kaiserludi admin
    edited July 2016
    Hi @Harish_Kagale.

    I am afraid that this is a problem of the network, not of Photon. It's pretty normal for 2G and often even 3G networks to provide latencies of several hundred milliseconds even to nearby servers.

    What can you do about it?
    1.
    Make sure to connect to the best server region. You might let your players choose a region to connect to in the UI or ping the regions or choose one best on the OS region settings. For example a client in Germany with an ethernet or WiFi connection may have the following pings to the various Photon server region:
    45ms to eu
    124ms to us east
    188ms to us west
    136ms to canada
    374ms to asia
    385ms to japan
    454ms to australia
    241ms to south america
    As you can see, the server region may make a difference of more than 400ms.
    However using a mobile connection will introduce additional latency of often a few hundred ms on top of those numbers from above, but something like 45+x is still better than 454+x, no matter what x is.

    2.
    Read about convergence algorithms and implement a suiting one for your game to hide latency from the player

    3.
    Add some input latency for the local player (when you get the input, immediately send it to the other players, but wait 100ms or so until you process it locally - this way the difference between when things happen on the local client and when they are transferred to remote clients gets reduced and if you keep the local input lag low enough, then it does not feel laggy because of the human reaction time).

    4.
    Send as few data as possible.
    A 2G network like GSM (not 2.5G like GPRS or 2.75G like Edge) has a bandwidth of only about 10kbit/s, which is 1.25kb/s, so if you send a 5kb message, there is no way it could be transferred in under 4 seconds and something like sending 50bytes every frame with a framerate of 60fps obviously can't work, as that would mean to try to push out about 3kb per second through a network, that doesn't even provide half of the bandwith needed for that.