i have a problem sending packets using UDP, getting two errors on the client side, the first one is *sometimes* (-> not always) happening and not critical:
NullReferenceException: Object reference not set to an instance of an object
TNet.GameClient.EndSend (Boolean reliable) (at Assets/TNet/Client/TNGameClient.cs:391)
TNManager.EndSend (Boolean reliable) (at Assets/TNet/Client/TNManager.cs:620)
RawPlayerSync.Update () (at Assets/Scripts/Player/RawPlayerSync.cs:43)
and this one, always occurring, kills the connection:
ArgumentOutOfRangeException: size must be >= 0
Parameter name: size
System.Net.Sockets.Socket.BeginSendTo (System.Byte[] buffer, Int32 offset, Int32 size, SocketFlags socket_flags, System.Net.EndPoint remote_end, System.AsyncCallback callback, System.Object state)
TNet.UdpProtocol.Send (TNet.Buffer buffer, System.Net.IPEndPoint ip) (at Assets/TNet/Common/TNUdpProtocol.cs:255)
TNet.GameClient.EndSend (Boolean reliable) (at Assets/TNet/Client/TNGameClient.cs:404)
TNManager.EndSend (Boolean reliable) (at Assets/TNet/Client/TNManager.cs:620)
RawPlayerSync.Update () (at Assets/Scripts/Player/RawPlayerSync.cs:43)
The Update-Function contains basicly this, i also tried the FixedUpdate:
BinaryWriter writer = TNManager.BeginSend(Packet.Test);
TNManager.EndSend(false);
i know that Update() means a lot of packets, the error is occurring after some time, like one minute, sometimes less, sometines more, so it is working in general.
The server just shows the client has disconnected after this error. i can then just reconnect and move around for a some seconds to a minute until it happens again.
I followed the Custom Packets tutorial, using the standalone server on localhost. The above code is using my custom "Test" packet. I boiled it down to this after it happend with some content in the packet in the first place. This it is the only packet using UDP. Other Update-Functions send packets using TCP, while also receiving a lot of data. If i silence the other traffic, the error seems not to happen, so it is maybe a threading/async io/locking issue?
I'am using unity 4.3.3 and the latest TNet on Windows 8.1.
Could there be an error on my side? How can i debug it? is it maybe a known error?
Thank you.