STUNErrorCodeAttribute System.ArgumentException
Been working on a project to forward RTSP streams over WebRTC. Pretty new to all this, so bear with me. The logging output and research I've done makes it seem that I need to be using a TURN server (not just a STUN server). Was using Stuntman before. Now using Pion. And I'm using version 6.0.9 of sipsorcery.
So, what's happening is that I apparently don't have TURN authentication set up right yet. As a result, Pion is sending a 401 unauthenticated error. Found that out by looking at a Wireshark trace. The STUNAttribute class is correctly parsing the attribute type as an error code. This particular error (and maybe others in the STUN protocol?) seems to send 4 bytes. The first two, according to Wireshark, are reserved as 0x0000. Then comes 0x04 (Error Class: 4). Finally, 0x01 (Error Code: 1).
These 4 bytes are then passed to the constructor of STUNErrorCodeAttribute. The first thing it does is this:
ErrorClass = (byte)BitConverter.ToChar(attributeValue, 2);
Unfortunately, BitConverter.ToChar apparently reads a unicode char, so this code is reading 2 bytes starting at position 2. Which I believe means it's reading the last 2 bytes. I think it should only read the next to last byte.
Then, the next line is where the ArgumentException happens (specifically that the destination array is not long enough):
ErrorNumber = (byte)BitConverter.ToChar(attributeValue, 3)
I think this should be reading the last byte, but seems to be reading the last byte and then trying to read past the end of the array.
I have the same issue too... PLEAZE how did you solve it?