简体   繁体   English

连接到EC2(AWS)上的C#服务器

[英]connect to C# server on EC2 (AWS)

I'm trying to connect to a C# TCP server I'm running on EC2. 我正在尝试连接到在EC2上运行的C#TCP服务器。 But my server's not responding. 但是我的服务器没有响应。 This is the code that running on the EC2: 这是在EC2上运行的代码:

static void Main(string[] args)
{
    TcpListener serverSocket = new TcpListener(8888);
    TcpClient clientSocket = default(TcpClient);
    serverSocket.Start();
    clientSocket = serverSocket.AcceptTcpClient();
    Console.WriteLine("new client connected");
}

And them from my own PC I'm trying to run this code: 他们是从我自己的PC上尝试运行以下代码的:

static void Main(string[] args)
{
    TcpClient clientSocket = new TcpClient();
    clientSocket.Connect("35.163.41.3", 8888);
    Console.WriteLine("you connected to the server!");
}

This is the security group of my EC2: 这是我的EC2的安全组:

安全组

What could the problem be? 可能是什么问题?

It could be a number of things. 可能有很多事情。 First thing I would check is Windows Firewall on the server to make sure that it is allowing that port. 我要检查的第一件事是服务器上的Windows防火墙,以确保它允许该端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM