.net: send UDP message does not working on Public IP

I am trying to send UDP message through WCF .net application to Android device, which working fine in LAN(Local Area Network) environment

but When I deploy that WCF service (MyService.svc) to PUblic IP (IIS) it sends UDP packet successfully but deice does not receive that packet.

Code to send UDP message

public void SendUDPMessage(IPEndPoint ipeSender, string Message)
{
    byte[] sendBytes = Encoding.ASCII.GetBytes(Message);
    if (serverSocket == null)
       serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
    serverSocket.BeginSendTo(sendBytes, 0, sendBytes.Length, SocketFlags.None, ((EndPoint)ipeSender), new AsyncCallback(OnSend), null);

}

Answers


Assuming the Android device is on a wireless/cellular network, it is effectively behind an NAT firewall and so any network traffic which originates externally will be blocked.

In order to punch through the NAT/firewall, the Android device needs to first send a message to the server. Then the server must respond to the exact address and port number that are given as the UDP messages' source.

NAT hole punching is a messy subject, which a lot of subtle issues. But it should work so long as the server has a real public IP address, the mobile device sends the first message, and you aren't doing any of the dozens of other things that can cause a UDP packet to be lost (packet larger than 1400 bytes, first few bytes look like a Teredo tunnel, server using a blocked port, sending data too quickly, server firewall misconfigured, etc.).


Need Your Help

Unable to update table containing hyphens in Linked Server to Progress Database using 10.2B ODBC drivers

sql-server-2008-r2 odbc linked-server progress-4gl openedge

I currently am using a Linked Server connection in Sql Server 2008 R2 to a Progress database using 10.2B ODBC drivers from Progress. I need to update a table, but the table name contains a hyphen ...

Sharing EntityFramework Datamodel

c# asp.net wpf entity-framework-4

I'm using EntityFramework 4 in my WPF desktop-application (NS: MyCompany.MyProduct).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.