我如何连接到EC2一个C#聊天服务器 [英] How do I connect to a c# chat server on ec2
问题描述
我在用C#聊天服务器。我都可以在本地主机上运行这一点,客户端可以连接到服务器。
I created a chat server with c#. I can run this all on localhost and the client can connect to the server.
我建立了一个亚马逊的EC2云计算服务。我设置了服务器上那儿,开始吧。我无法从我的客户端连接到服务器运行在我的EC2实例我家里的电脑上运行。
I set up an Amazon EC2 cloud service. I set up the server on there and started it. I cannot connect to the server running in my ec2 instance from my client running on my home computer.
我建立了一个弹性的IP地址。然后,我就分配给正在运行的服务器实例。
I set up an elastic IP address. I then assigned it to the instance that's running the server.
我设置的安全组,如下所示:
I set up the security group as follows:
我现在可以ping我的服务器,但我的客户端仍然无法连接到服务器。 (我知道开放安全组有一点是危险的,但是这是一个学校项目,所以我只需要它运行在一个时间5分钟)
I can now ping my server, but my client still cannot connect to the server. (I realize opening up the security group this much is dangerous, but this is for a school project so I only need it to run 5 minutes at a time)
我在想什么?我怎样才能让我的客户端连接到我的服务器?
What am I missing? How can I get my client to connect to my server?
推荐答案
检查源$ C $ c代表的TcpListener绑定。它应该听的所有IP地址,而不是本地主机,这是一个常见的错误。使用IPAddress.Any。
Check your source code for the TcpListener binding. It should listen to all IP addresses rather than the localhost, which is a common mistake. Use IPAddress.Any.
这篇关于我如何连接到EC2一个C#聊天服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!