Open Hecto-r opened 2 years ago
Same problem here:
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.' StackTrace = " at Protocol16.Photon.NumberDeserializer.Deserialize(Int32& value, Byte[] source, Int32& offset)\r\n at PhotonPackageParser.PhotonParser.HandleCommand(Byte[] source, Int32& offset)\r\n at PhotonPackageParser.PhotonParser.ReceivePacket(Byte[] payload)...
What can we do?
same here.
@Hecto-r @Triky313 were you able to fix the problem?
@bonesoul Nope. Just try catch. :/
i got a same problem,Can u send me some email or discord?
Hello. This occurs when processing custom packages. They cannot be processed. The solution is try/catch at the parser call site.
i attempt to try/catch at the parser call site like this
private void PacketHandler(object sender, CaptureEventArgs e)
{
try
{
UdpPacket packet = Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data).Extract
}
but i cant go in to OnRequest or OnResponse that mean is the packages has change right?
try { var packet = Packet.ParsePacket(e.GetPacket().LinkLayerType, e.GetPacket().Data).Extract();
if (packet != null && (packet.SourcePort == 7656 || packet.DestinationPort == 7656))
{
Console.WriteLine("packet: " + packet.PayloadData.Length);
_receiver.ReceivePacket(packet.PayloadData);
}
}
catch (Exception exc)
{
ConsoleManager.WriteLineForError(MethodBase.GetCurrentMethod()?.DeclaringType, exc);
Log.Error(nameof(Device_OnPacketArrival), exc);
}
I've printed the lengths of the packet.PayloadData. This is the prints.
packet: 58
Exception thrown: 'System.IndexOutOfRangeException' in PhotonPackageParser.dll
packet: 44
Exception thrown: 'System.IndexOutOfRangeException' in PhotonPackageParser.dll
packet: 236
Why is it throwing this exception?