question

Verox007-2861 avatar image
0 Votes"
Verox007-2861 asked JiangZhang-MSFT commented

NET UDP don't work

I wrote two UDP-Sockets. One for client, one for server. As long, as I use them one my local system the server receives the message from the client correctly, But if I try it to setup it on my vps and using the client on my computer, i don't work anymore. I checked incoming connections on my VPS and there aren't any. Could it be that the client can't send the packet to extern network?

Server:

 public partial class Network
     {
         private UdpClient Socket { get; set; }
         private IPEndPoint EpFrom = new IPEndPoint(IPAddress.Any, 0);
    
         public void Bind(string address, int port)
         {
             this.Socket = new UdpClient(new IPEndPoint(IPAddress.Parse(address), port));
             Receive();
         }
    
         public void Send(string text)
         {
             byte[] data = Encoding.ASCII.GetBytes(text);
             Socket.Send(data, data.Length);
         }
    
         private void Receive()
         {
             Console.WriteLine("Hearing on localhost 11111");
             byte[] data = Socket.Receive(ref EpFrom);
             Console.WriteLine(Encoding.ASCII.GetString(data));
         }
     }

Call:

 static void Main(string[] args)
         {
             // Server.Start();
             Network server = new Network();
             server.Bind("127.0.0.1", 11111);
         }

Client:

 public class Network
     {
         private UdpClient Socket { get; set; }
         private IPEndPoint EpFrom = new IPEndPoint(IPAddress.Any, 0);
    
         public void Client(string address, int port)
         {
             this.Socket = new UdpClient(port);
             this.Socket.Connect(new IPEndPoint(IPAddress.Parse(address), port));
         }
    
         public void Send(string text)
         {
             byte[] data = Encoding.ASCII.GetBytes(text);
             Socket.Send(data, data.Length);
             Socket.Close();
         }
    
         private void Receive()
         {
             Console.WriteLine("Hearing on localhost 11111");
             byte[] data = Socket.Receive(ref EpFrom);
             Console.WriteLine(Encoding.ASCII.GetString(data));
         }
     }

Call:
static void Main(string[] args)
{
Network client = new Network();
client.Client("144.91.74.110", 8888);
client.Send("test");
}


windows-10-network
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

You could accept the useful reply as answer if you want to end this thread up.
If there is anything else i can do for you, please feel free to post in the forum.

Mulder

0 Votes 0 ·

Hi,
I'm wondering if you could fix the issue. And is there anything else we can do for you or something new you wanna bring it up, please feel free to post.

Best Regards,
Mulder Zhang

0 Votes 0 ·
JiangZhang-MSFT avatar image
0 Votes"
JiangZhang-MSFT answered JiangZhang-MSFT edited

Hi,

In your case, we might need to analyze network traffic to find some clues. However, Analysis of network traffic is beyond our support scope. Due to the security policy of the Forum, we don’t have the privilege to collect user' data logs, so we suggest that you open a case to Microsoft.

The following is the link for the case submission:

https://support.microsoft.com/en-us/gp/contactus81?forceorigin=esmc&Audience=Commercial&wa=wsignin1.

Best Regards,
Mulder Zhang


If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Verox007-2861 avatar image
0 Votes"
Verox007-2861 answered

Hello. I tested it one my Windows PC and it also didn't work extern. It just works intern on linux and windows. The system is irrelevant I think.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JiangZhang-MSFT avatar image
0 Votes"
JiangZhang-MSFT answered Verox007-2861 commented

Hi,

I looked into your UDP-Sockets code, and I didn’t dig up anything wrong with your code from my side. I’m wondering if your VPS setup was right?

The following link is how to build a basic UDP socket on client and server in windows that you may refer to.
https://docs.microsoft.com/en-us/windows/uwp/networking/sockets#build-a-basic-udp-socket-client-and-server

Down below is the link for vps-connection-troubleshooting methods. You could open a ticket if you need any further assistance here.
https://www.hostwinds.com/tutorials/vps-connection-troubleshooting

Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.



Best Regards,
Mulder Zhang


If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your support. I already followed the first link, you sent. I have Debian 10 with dotnet and .NET Core 5 as runtime. Also I opened the port 11111 with ufw. Is there anything else?

0 Votes 0 ·
JiangZhang-MSFT avatar image
0 Votes"
JiangZhang-MSFT answered

Hi,

I'm currentlly working with your case and will get it back to you ASAP.

Mulder

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.