问题描述
背景:
我正在使用:
-
AWS EC2
1a。打开端口 80/443(我使用这些端口的要求)
1b。使用 Python 监听连接/消息
def multi_threaded_client_listen(self,connection):
try:
while True:
try:
data = connection.recv(1024)
if not data:
break
else:
print("Data: {}".format(data))
except Exception:
print("1",traceback.format_exc())
except ConnectionResetError:
print("IGnorE - Connection Reset Error")
except Exception:
print("2",traceback.format_exc())
-
Rust 作为我的前端
2a。在 80 上建立连接
2b。通过此连接发送消息
async fn Send(connection: Connection2,string: String) -> Result<(),ConnectionError> {
let mut stream = connection.stream.lock().await;
stream.write_all(string.as_bytes()).await.map_err(|_| ConnectionError::SendError(connection.loc))?;
Ok( () )
}
我在发送第一条消息时仅收到以下错误。
1 回溯(最近一次调用最后一次): 文件“/home/ec2-user/ConnectionFiles/Connection.py”,第 40 行,在 multi_threaded_client_listen 数据 = connection.recv(1024) ConnectionResetError: [Errno 104] 对等方重置连接
事件顺序:
-
连接到服务器 ( Works ) 上的 80 端口
-
发送我的第一条消息(给我 ConnectionResetError 然后重新连接)
-
我可以像什么都没发生一样发送后续消息(有效)
服务器输出:
Ports: [80,443]
opening Socket On Port: 80
opening Socket On Port: 443
Address: ('166.137.248.58',49255) -- Port: 80
1 Traceback (most recent call last):
File "/home/ec2-user/ConnectionFiles/Connection.py",line 40,in multi_threaded_client_listen
data = connection.recv(1024)
ConnectionResetError: [Errno 104] Connection reset by peer
Address: ('107.77.233.23',58261) -- Port: 80
Data: b'1st Message'
Data: b'2nd Message'
注意事项:
我尝试更改端口 - 只是为了提供信息 - 并且它有效。我没有收到这个错误。 80 端口问题?
问题:
为什么我在端口 80 上发送的第一条消息(不是连接)上收到 ConnectionResetError
,然后自动重新连接并发送消息?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)