简体   繁体   English

python3.8 http.server - ConnectionResetError: [Errno 104] 对等方重置连接

[英]python3.8 http.server - ConnectionResetError: [Errno 104] Connection reset by peer

I've set up a simple http server to share some files with a friend.我设置了一个简单的 http 服务器与朋友共享一些文件。 I know there are other ways of sharing files, but I'm interested in doing it this way and solving the issues raised.我知道还有其他共享文件的方法,但我有兴趣这样做并解决提出的问题。

The server side code is simple:服务器端代码很简单:

 #!/bin/bash
 /usr/bin/python3 -u -m http.server -d /srv/carmine 2339

where carmine is a directory containing files.其中carmine是一个包含文件的目录。

I can access files through localhost:2339 and my friend can download files and reports no error on their side, but my logs show this:我可以通过localhost:2339访问文件,我的朋友可以下载文件并且他们这边没有报告错误,但我的日志显示:

   Exception happened during processing of request from ('xxxxxxxxx', 55664)
   Traceback (most recent call last):
     File "/usr/lib/python3.8/socketserver.py", line 650, in process_request_thread
       self.finish_request(request, client_address)
     File "/usr/lib/python3.8/socketserver.py", line 360, in finish_request
       self.RequestHandlerClass(request, client_address, self)
     File "/usr/lib/python3.8/http/server.py", line 647, in __init__
       super().__init__(*args, **kwargs)
     File "/usr/lib/python3.8/socketserver.py", line 720, in __init__
       self.handle()
     File "/usr/lib/python3.8/http/server.py", line 427, in handle
       self.handle_one_request()
     File "/usr/lib/python3.8/http/server.py", line 415, in handle_one_request
       method()
     File "/usr/lib/python3.8/http/server.py", line 654, in do_GET
       self.copyfile(f, self.wfile)
     File "/usr/lib/python3.8/http/server.py", line 853, in copyfile
       shutil.copyfileobj(source, outputfile)
     File "/usr/lib/python3.8/shutil.py", line 205, in copyfileobj
       fdst_write(buf)
     File "/usr/lib/python3.8/socketserver.py", line 799, in write
       self._sock.sendall(b)
   ConnectionResetError: [Errno 104] Connection reset by peer
   

What is happening here?这里发生了什么? Do I need to set some server side parameters?我需要设置一些服务器端参数吗?

This message means that the other side of the connection "hung up" on your server.此消息意味着连接的另一端在您的服务器上“挂起”。 This could have happened for a number of reasons: you canceled a file download, someone killed a program accessing your http server, or a large file caused a client timeout while downloading, among other things.发生这种情况的原因有很多:您取消了文件下载,有人杀死了访问您的 http 服务器的程序,或者大文件导致客户端在下载时超时,等等。

Right now you're using the default SimpleHTTPRequestHandler .现在您正在使用默认的SimpleHTTPRequestHandler If you're curious what caused the error and wanted to, you could create a subclass of it and write some logging functions that would tell you things like 1. what IP is accessing your server, 2. request parameters, 3. what file they're attempting to download, etc.如果您想知道是什么导致了错误并且想要,您可以创建它的子类并编写一些日志记录函数,这些函数会告诉您以下内容:1. IP 正在访问您的服务器,2. 请求参数,3. 它们是什么文件'正在尝试下载等。

暂无
暂无

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

相关问题 ConnectionResetError:[Errno 104]由对等Python 3重置连接 - ConnectionResetError: [Errno 104] Connection reset by peer python 3 connectionreseterror: (errno 104) 连接被对等方重置 - connectionreseterror: (errno 104) connection reset by peer Python套接字ConnectionResetError:[Errno 54]对等方与socket.error的连接重置:[Errno 104]对等方重置连接 - Python socket ConnectionResetError: [Errno 54] Connection reset by peer vs socket.error: [Errno 104] Connection reset by peer Google colab 下载 - ConnectionResetError: [Errno 104] Connection reset by peer - Google colab download - ConnectionResetError: [Errno 104] Connection reset by peer 如何修复“ConnectionResetError: [Errno 104] Connection reset by peer”错误? - How to fix "ConnectionResetError: [Errno 104] Connection reset by peer" error? ConnectionResetError:[Errno 104] 连接被特定网站的对等方重置 | Python3 - ConnectionResetError: [Errno 104] Connection reset by peer from specific website | Python3 在Python 2.7中由peer [errno 104]重置连接 - Connection reset by peer [errno 104] in Python 2.7 在Python中由对等[Errno 104]重置连接 - Connection reset by peer [Errno 104] in Python ConnectionResetError:[Errno 104]由对等方和ERR_NAME_NOT_RESOLVED在heroku上重置连接,并通过Selenium进行了移动测试 - ConnectionResetError: [Errno 104] Connection reset by peer and ERR_NAME_NOT_RESOLVED on heroku with mobile testing through Selenium 错误:[Errno 104]由对等方重置连接-开发服务器IE 9 - error: [Errno 104] Connection reset by peer - dev server IE 9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM