'Make requst to stun server (Coturn)
Im create a coturn server and check it by TrickleICE https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ . Its work. Now i want to write simple client. I
m connect to server by UDP client:
udpClient = new UdpClient();
IPAddress ipAddress = IPAddress.Parse(IpAddress);
ipEndPoint = new IPEndPoint(ipAddress, Port);
try
{
udpClient.Connect(ipEndPoint);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
Then i create header and attribyte byte arrays like it described here: https://datatracker.ietf.org/doc/html/rfc5766
Creating header example:
byte[] header = new byte[20];
byte[] messageT = BitConverter.GetBytes((Int16)messageType);
byte[] messageLength;
messageLength = BitConverter.GetBytes((Int16)attributeLength);
byte[] TransactionId = MyTransactionByteArray
messageT.CopyTo(header, 0);
messageLength.CopyTo(header, 2);
TransactionId.CopyTo(header, 4);
When I send header without any attrubutes by stun protocol (https://datatracker.ietf.org/doc/html/rfc3489#section-11.1) server logs says:
handle_udp_packet: New UDP endpoint: local addr 0.0.0.0:10000, remote addr "myip":"port"
Wrong OLD STUN message received
With attributes(like here: https://datatracker.ietf.org/doc/html/rfc5766#section-16):
handle_udp_packet: New UDP endpoint: local addr 0.0.0.0:10000, remote
addr "myip":"port"
And I am not getting any response.
IPEndPoint ip = null;
byte []msg = udpClient.Receive(ref ip);
Where did i go wrong?
Solution 1:[1]
Ok. just use this header from newest stun protocol: https://datatracker.ietf.org/doc/html/rfc5389
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | soniko62 |