Sending series of packets causes disconnection

Siegfried
edited October 2012 in Native
Hello!
I have a problem: our game needs to send about 150kb of data between players now and then...
Client A splits that 150kb of data into 6000B chunks and sends it reliable way to other party. Everything seems ok here.

Now, the receiving Client B gets 3-4 packets and then it reports connection error 1041 (SC_DISCONNECT_BY_SERVER).

Any idea what causes it and how to make it work? I am calling photon update every frame
Regards!

Comments

  • Are you using udp or tcp and are you connecting to a server on localhost or on another machine?
  • I am using photon cloud with LoadBalancingClient, connecting two machines on our network

    also, I am getting these warning just before disconnection:

    WARNING enetpeer.cpp ExitGames::EnetPeer::dispatchIncomingCommands()
    line: 308 - do not dispatch if that command is not the very next one available (this is reliable)

    it goes for about 40 times an then we get
    INFO enetpeer.cpp ExitGames::EnetPeer::execute()
    line: 853 - Info: Server sent disconnect because of timeout PeerId: 8xx, RTT/Variance 82/11

    connection error is 1041
  • From the debug out I can see, that you are using udp. Does this also happen, when you try with tcp?
    It should definitely also work with udp and our tests for sending such chunks are running just fine.

    Could you make a reproduction case, so that we can see, if we can reproduce it here?
  • when I use tcp game disconnects a lot, so I cannot go from lobby into actual game :(

    I am unable to give you any reproduction case right now , but here's some code:

    processing packet:

    [code2=cpp]customEventAction(int playerNr, nByte eventCode, const ExitGames::Hashtable& eventContent)
    {
    switch((int)eventCode)
    {
    case MP_ID_INGAME_PACKET:
    {
    int command = ((ExitGames::ValueObject<int>)(eventContent.getValue(ExitGames::KeyObject<nByte>((nByte)MP_ARG_ID_COMMAND)))).getDataCopy();


    switch(command)
    {

    (...)

    case PACKETTYPE_REPLAYDATA:
    {
    unsigned char *ptr = (unsigned char*) &crunch;
    PACKET_REPLAY_DATA *p = (PACKET_REPLAY_DATA *)((ExitGames::ValueObject<nByte*>)(eventContent.getValue(ExitGames::KeyObject<nByte>(MP_ARG_ID_DATA)))).getDataCopy();
    memcpy(&ptr[p->index * 6000], &p->data,6000);
    printf("PHOTON: GOT PACKETTYPE_REPLAYDATA %d\n",p->index);

    }
    break;
    }

    }

    }

    }[/code2]


    should I do sth after I process the packet? I tried:
    mLoadBalancingClient.dispatchIncomingCommands();
    mLoadBalancingClient.sendOutgoingCommands();
    mLoadBalancingClient.serviceBasic();
    after processing this type of packet, but it doesnt help, any ideas?
    regards
  • Please try, if it helps, when you call sendOutgoingCommands() more often on client B in this situation. Maybe it is just not getting out the acknowledgments for the received reliable commands fast enough.

    Hmm, could it be hat you have a very unstable connection? That would explain, why your have so many tcp connection losses.

    From where are you connecting to the cloud? US, Europe, Asia, or somewhere else?
  • ok, I will try do sendOutgoingCommands more often
    also, looks like it works better if i change size of the packet to sth smaller - 900 bytes. But then it takes way too long to deliver all that packets

    We are connecting to Cloud from UK
  • hmmm... on the client i am getting this message:
    WARNING enetpeer.cpp ExitGames::EnetPeer::queueIncomingCommand() line 710 - WARNING! There are 100 incoming messages waiting in the local incoming reliable message queue of channel 205!

    It's strange because my update code is:

    [code2=cpp]mLoadBalancingClient.service();

    max = mLoadBalancingClient.getQueuedIncomingCommands();
    if(max > 9 )
    max = 9;
    for ( i = 0; i < max; i++)
    {
    mLoadBalancingClient.dispatchIncomingCommands();
    }

    max = mLoadBalancingClient.getQueuedOutgoingCommands();
    if( max > 9)
    max = 9;
    for ( i = 0; i < max; i++)
    {
    mLoadBalancingClient.sendOutgoingCommands();
    }[/code2]

    am i missing something here?
  • The first loop isn't needed needed, as service() calls dispatchIncomingCommands in a while-loop anyway.

    Why are you trying to send on channel 205? I can't imagine, that you need more than 200 channels.

    The native Clients currently have their default number of channels set to 20 and for now this value is hardcoded, so only channels 0-19 will work and using anything beyond that won't work.
  • @all: We have found the cause of the problems.
    In Client::onEvent() the first line is:
    PhotonPeer_sendDebugOutput(this, DEBUG_LEVEL_INFO, eventData.toString(true)
    If you want to send around events, that are multiple kb in size, then you should remove the true and just call toString() without passing any parameters, so that it will only print the event code and not the payload, as eventData.toString() gets just too expensive for really big events.

    From the 3.0.4.0 release on this change to Client::onEvent() will be included in the SDK, same as the according change in its objC equivalent LoadBalancingClient::onEvent().