Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown: 'System.IndexOutOfRangeException' in PhotonPackageParser.dll #11

Open
Hecto-r opened this issue Sep 9, 2022 · 7 comments

Comments

@Hecto-r
Copy link

Hecto-r commented Sep 9, 2022

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?

@Triky313
Copy link

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?

@bonesoul
Copy link

bonesoul commented May 7, 2023

same here.

@bonesoul
Copy link

@Hecto-r @Triky313 were you able to fix the problem?

@Triky313
Copy link

@bonesoul Nope. Just try catch. :/

@toutouxue
Copy link

i got a same problem,Can u send me some email or discord?

@DocTi
Copy link
Contributor

DocTi commented May 17, 2023

Hello. This occurs when processing custom packages. They cannot be processed. The solution is try/catch at the parser call site.

@toutouxue
Copy link

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();
if (packet != null && (packet.SourcePort == 43825 || packet.DestinationPort == 43825))
{
photonParser.ReceivePacket(packet.PayloadData);
}
}
catch (System.Exception)
{
System.Console.WriteLine(e);
}
}
but i cant go in to OnRequest or OnResponse that mean is the packages has change right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants