Use transport layer ,client side stop response

below is server side performance

public  byte[] collectData()
    {
            byte[] syncbytes;
        //if (isSever && isPlaying)
        {
            players = GameObject.FindGameObjectsWithTag("Player");
            enemys = GameObject.FindGameObjectsWithTag("enemy");
           // weapon= GameObject.FindGameObjectsWithTag("weapon");
            tmpContainer = new GameObject[][] { players, enemys };
            int activeGobjnum = players.Length + enemys.Length;
            activeObj =new GameObject[activeGobjnum];
           // SyncPosition = new Vector3[activeGobjnum];
            players.CopyTo(activeObj, 0);
            enemys.CopyTo(activeObj, players.Length);
            int id;
       
            BaseContol objectstate;
            SynchronizationMessage.Clear();
            for(int i=0;i<tmpContainer.Length;i++)
            {
           
                GameObject[] g = tmpContainer[i];
                foreach (GameObject g1 in g)
                {
                    objectstate = g1.GetComponent<BaseContol>();
                    id = objectstate.NetworkId;
                    byte FireState = objectstate.bullect;
                    if (id == -1)
                    {
                        enemycounter += 1;
                        objectstate.NetworkId = enemycounter;
                        SynchronizationMessage.Add(g1.name+ enemycounter, new Gamobjectsinfo(objectstate.NetworkId, new byte[] { FireState }, g1.transform.position, g1.transform.rotation));
                        Debug.Log(g1.name+"-counter=" + enemycounter);
                    }
                    else
                    {
                        SynchronizationMessage.Add(g1.name+id, new Gamobjectsinfo(id, new byte[] { (byte)FireState }, g1.transform.position, g1.transform.rotation));
                    }

                    objectstate.bullect = 0;

                }
            }

       }

below is both side initialize setting

 void init()
    {
        if (hostId != -1)
            return;
        NetworkTransport.Init();
        config = new ConnectionConfig();
        channelid = config.AddChannel(QosType.ReliableFragmented);
        HostTopology topology = new HostTopology(config, 15);
        // hostId = NetworkTransport.AddHost(topology);
        Debug.Log("hostId1=" + hostId);
        hostId = NetworkTransport.AddHost(topology, broadcastPort);
    }

receive code is

    int outHostId;
        int outConnectionId;
        int outChannelId;
        string outConnIp;
        int outPort;
        NetworkID outID;
        NodeID outNode;
        int receivedSize;
        byte error;
        int quesize;
        NetworkEventType evt;
        int dog = 0;
        do
        {
            dog++;
            buffer = new byte[1024];
            evt =
NetworkTransport.Receive(out outHostId, out outConnectionId, out outChannelId, buffer, buffer.Length, out receivedSize, out error);
            quesize = NetworkTransport.GetIncomingMessageQueueSize(outHostId, out error);
            if (error != 0)
                Debug.LogError("Receive error=" + error + "quesize=" + quesize);
            switch (evt)
            {
                case NetworkEventType.ConnectEvent:
                    {
                        NetworkTransport.GetConnectionInfo(outHostId, outConnectionId, out outConnIp, out outPort, out outID, out outNode, out error);
                        connectionClient.Add(outConnectionId, new StrTxt(Instantiate(text), outConnIp, true));
                        OnConnect(outHostId, outConnectionId, (NetworkError)error);
                        break;
                    }
                case NetworkEventType.DisconnectEvent:
                    {
                        OnDisconnect(outHostId, outConnectionId, (NetworkError)error);
                        break;
                    }
                case NetworkEventType.DataEvent:
                    {
                     
                        OnData(outHostId, outConnectionId, outChannelId, buffer, receivedSize, (NetworkError)error);
                        break;
                    }
                case NetworkEventType.BroadcastEvent:
                    {
                        OnBroadcast(outHostId, buffer, receivedSize, (NetworkError)error);
                        break;
                    }
                case NetworkEventType.Nothing:
                    break;

                default:
                    Debug.LogError("Unknown network message type received: " + evt);
                    break;
            }


        }
        while (dog<30&&quesize!=0);

I test this on wifi.Use a windows device and another is android device.
When I send message over 1024 bytes , receive device’s application will on response
even in editor.Therefore I have to use task manager close unity.
Is anyone know how to solve this?
This cause me use QosType.ReliableSequenced channel.I split large (over 1024 bytes) to chunks.
Combine that at client.But when client receive some times message.It’s no response.
My unity versions is 5.60f3. I use VisualStudio2015,windows10 Os.
Any help here would be greatly appreciated.

@lifeFo I do not see any error in your code. Please generate bug (with repro steps and description) and ping me with it’s number. I will take a look on the next week

@lifeFo oop I know whats happened - your buffer size is 1024, check please two parameters from Receive out receivedSize, out error. error should be MessageTooLong and receivedSize will return the actual message size. Probably you will need to increase your buffer

@aabramychev Is QosType.ReliableFragmented fragmented message automatically? As i said before when send bytes over 1024.Receive side will lost control immediately and send side every thing is fine(error=0).So I can’t see what happened from LOG.It’s also happened when I use reliable channel(I split large message to chunks which not over 1024 byte) which after receive several times.

@lifeInfo, yes it is. +it assembles them automatically too. For ex

You send 4k - 1k 1k 1k 1k - (on receiver) 4 k… Other words if you send 4k, you should receiev 4k too, if your buffer is 1k i will never receive 4k. Check please error and received size

@aabramychev As you said,I adjust my buffer size.My send side code is

 public void sendmessage(int ID, byte[] msg, int Type)
    {
byte error = new byte();
        string form = Type + "," + msg.Length+","+"HEAD";// + "," + "HEAD";
        Debug.Log("msgHEAD = " + form+'|');
        byte[] msgInfo = GetBytes(form);
 
        NetworkTransport.Send(hostId, ID, channelid, msgInfo, msgInfo.Length, out error);
        Debug.Log("connectionIdHead  " + connectionId + " error= " + error.ToString()+" channelid="+channelid);
        NetworkTransport.Send(hostId, ID, channelid, msg, msg.Length, out error);
}

receive side is

int receiveMsgType;
    bool isHaed = true;
    int  GetSize;
    int conuter = 0;
byte[] buffer=new buffer[1024];//receive buffer
    private void OnData(int outHostId, int outConnectionId, int outChannelId, byte[] buffer, int receivedSize, NetworkError error)
    {
        Debug.Log("Entry OnData receive size="+buffer.Length+ "receivedSize"+ receivedSize);
 
        if (isHaed)
        {
            byte[] reallyBytes = new byte[receivedSize];
            Array.Copy(buffer, 0, reallyBytes, 0, receivedSize);
            Debug.Log("!= HEAD?"+GetString(reallyBytes)+ "!= HEAD?");
            string[] s = splitString(reallyBytes);
          //  Debug.Log("s[2]=" + s[2] +"!= HEAD?");
         //   if (s[2] != "HEAD")
         //       return;
            isHaed = false;
            GetSize = int.Parse(s[1]);
            this.buffer = new byte[GetSize];//adjust buffer size to hold data
            receiveMsgType = int.Parse(s[0]);
            Debug.Log("receiveMsgType"+receiveMsgType);
            Debug.Log("GetSize=" + GetSize);
            return;
        }
        Debug.Log("Entry Receiver");
        if (receiveMsgType == msgType.testMessage)
        {
            Debug.Log("Receive test message=" + NetWorkAdapter.GetString(buffer));
            isHaed = true;
            return;
        }

When I send message low frequently ,basically fine(although sometimes with wrong sequence and duplicate).
But if I send info like this

              byte[] b= new byte[1390];
              while (e++ < 15)
                {
                    sendmessage(id, b, msgType.testMessage);
                }

or this

 tempTime=0;
void Update()
    {
        if (GaneStart)
        {
            tempTime += Time.deltaTime;
            if (tempTime > 0.1)
            {

                tempTime = 0;
                syncData();//send object data
                //    Debug.Log("datasize=" +collectData().Length);
            }
        }
    
    }

Receive will no response immediately and simultaneously I can’t see any log info.
But at send side error=0.
I use above code synchronization game data.Any suggestion? And thanks for your reply.:slight_smile: