gpt4 book ai didi

Python Thrift RPC 不适用于 EC2

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:48 24 4
gpt4 key购买 nike

我正在尝试使用将在 EC2 上运行的 Thrift 创建一个简单的客户端/服务器应用程序。

我创建的示例对本地主机非常有效,但是当我尝试在 ec2 上的两台不同机器上进行 RPC 调用时(两台机器都单独分配了弹性 IP 地址),它不起作用并出现以下错误:

raceback (most recent call last):
File "SocialQClient.py", line 25, in <module>
transport.open()
File "/usr/local/lib/python2.6/dist-packages/thrift/transport/TTransport.py", line 150, in open
return self.__trans.open()
File "/usr/local/lib/python2.6/dist-packages/thrift/transport/TSocket.py", line 90, in open
raise TTransportException(type=TTransportException.NOT_OPEN, message=message)
thrift.transport.TTransport.TTransportException: Could not connect to <MY-ELASTIC-IP>:9090

我在两台机器上为 TCP 端口 9090 设置了 0.0.0.0/0 安全组。我也试过 UDP,但没有解决。我做错了什么?

更新:

最佳答案

我大胆猜测,当您的一个 ec2 实例(“node1”)尝试对另一个 ec2 实例(“node2”)进行 RPC 调用时,node2 会返回其内部 IP 地址。

引用 - http://alestic.com/2009/06/ec2-elastic-ip-internal

引用:

This last option uses a little-known feature of the Elastic IP Address system as implemented by Amazon EC2:

When an EC2 instance queries the external DNS name of an Elastic IP, the EC2 DNS server returns the internal IP address of the instance to which the Elastic IP address is currently assigned.

这里有一些示例说明了 dig 如何返回不同的值,将您使用 Amazon 外部的机器来 ping 一个 ec2 实例的场景与您使用一个 ec2 实例来 ping 另一个 ec2 实例的场景进行比较:-

This is the permanent external DNS name for that Elastic IP address no matter how many times you change the instance to which it is assigned. If you query this DNS name from outside of EC2, it will resolve to the external IP address as shown above:

$ dig +short ec2-75-101-137-243.compute-1.amazonaws.com
75.101.137.243

However, if you query this DNS name from inside an EC2 instance, it will resolve to the internal IP address for the instance to which it is currently assigned:

$ dig +short ec2-75-101-137-243.compute-1.amazonaws.com
10.254.171.132

关于Python Thrift RPC 不适用于 EC2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7490015/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com