Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

net::ERR_CONNECTION_RESET when large file takes longer than a minute

I have a multipart file upload in a form with a php backend. I've set max_execution_time and max_input_time in php.ini to 180 and confirmed on the file upload that these values are set and set TimeOut 180 in Apache. I've also set

RewriteRule .* - [E=noabort:1]
RewriteRule .* - [E=noconntimeout:1]

When I upload a 250MB file on a fast connection it works fine. When I'm on a slower connection or a network link conditioner to artificially slow it down, the same file times out and on Chrome gives me net::ERR_CONNECTION_RESET after 1 minute (and 5 seconds) reliably. I've also tried other browsers with the same outcome, just different error messages.

There is no indication to an error in any log and I've tried both on http and https.

What would cause the upload connection to be reset after 1 minute?

EDIT

I've now also tried to have a simple upload form that bypasses any framework I'm using, still timeouts at 1 minute.

I've also just made a sleep script that timeouts after 2 and a half minutes, and that works, page takes around 2.5 minutes to load so I can't see how it's browser or header related.

I've also used a server with more RAM to ensure it's not related to that. I've tested on 3 different servers with different specs but all from the same CentOS 7 base.

I've now also upgraded to PHP 7.2 and updated the relevant fields again with no change in the problem.

EDIT 2 The tech stack for this isolated instance is

  • Apache 2.4.6
  • PHP 5.6 / 7.2 (tried both), has OPCache
  • Redis 3.2.6 for session information and key / value storage (ElastiCache)
  • PostgreSQL 10.2 (RDS)

Everything else in my tech stack has been removed from this test area to try and isolate the problem. EFS is on the system but in my most isolated test it's just using EBS.

EDIT 3 Here some logs from the chrome network debugger:

{"params":{"net_error":-101,"os_error":32},"phase":0,"source":    {"id":274043,"type":8},"time":"3332701830","type":69},
{"params":    {"error_lib":33,"error_reason":101,"file":"../../net/socket/socket_bio_adapter.cc","line":216,"net_error":-101,"ssl_error":1},"phase":0,"source":        {"id":274043,"type":8},"time":"3332701830","type":56},
{"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":159},
{"phase":1,"source":    {"id":274038,"type":1},"time":"3332701830","type":164},
{"phase":1,"source":    {"id":274038,"type":1},"time":"3332701830","type":287},
{"params":    {"error_lib":33,"error_reason":101,"file":"../../net/socket/socket_bio_adapter.cc","line":113,"net_error":-101,"ssl_error":1},"phase":0,"source":    {"id":274043,"type":8},"time":"3332701830","type":55},
{"params":{"net_error":-101},"phase":2,"source":    {"id":274038,"type":1},"time":"3332701830","type":287},
{"params":{"net_error":-101},"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":164},
{"params":{"net_error":-101},"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":97},
{"phase":1,"source":{"id":274038,"type":1},"time":"3332701830","type":105},
{"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":105},
{"phase":2,"source":{"id":274043,"type":8},"time":"3332701830","type":38},
{"phase":2,"source":{"id":274043,"type":8},"time":"3332701830","type":38},
{"phase":2,"source":{"id":274043,"type":8},"time":"3332701830","type":34},
{"params":{"net_error":-101},"phase":2,"source":{"id":274038,"type":1},"time":"3332701830","type":2},
like image 408
Rudiger Avatar asked Dec 12 '18 05:12

Rudiger


People also ask

What does it mean when a website says the connection was reset?

If you see the “connection was reset” error message it means the connection was not established correctly and has been reset. How to solve the connection reset problem? If you see the following error “this site can't be reached the connection was rest” try checking your internet and VPN.

What does the connection was reset mean on Chrome?

A connection reset message can be caused by several situations, but they all mean the same thing. The link between your web browser and the webserver you are trying to reach is blocked or not working. You can troubleshoot some of this path but not all of it.

Can't reach this page connection was reset?

The 'ERR_CONNECTION_RESET' error often occurs because of proxy settings. A proxy server may be blocking the internet connection to a particular site. It may have been entered manually or by an app. Search for and open Internet Options under Control Panel from the Start menu.

What is an err_connection_reset error?

Connection reset errors appear when you visit a website, and the browser fails to establish a connection. When that happens, the connection is “reset,” which means the server cannot transmit data to your browser. Here’s what the “ERR_CONNECTION_RESET” message looks like in Chrome:

What happens when a browser gets an error of connection close?

If a browser gets an error of connection close while sending data, the browser has no chance to read a response from the server. If the server uses shutdown, the browser does not get an error of connection close, then it gets chance to read a response. This might change the situation.

What does it mean when Firefox says connection was reset?

For example, Firefox returns a “The connection was reset” error code. Connection reset errors appear when you visit a website, and the browser fails to establish a connection. When that happens, the connection is “reset,” which means the server cannot transmit data to your browser.

Why can’t I read a response from the server?

If a browser gets an error of connection close while sending data, the browser has no chance to read a response from the server. If the server uses shutdown, the browser does not get an error of connection close, then it gets chance to read a response. This might change the situation. Sorry, something went wrong.


1 Answers

Original source here

ERR_CONNECTION_RESET usually means that the connection to the server has ceased without sending any response to the client. This means that the entire PHP process has died without being able to shut down properly.

This is usually not caused by something like an exceeded memory_limit. It could be some sort of Segmentation Fault or something like that. If you have access to error logs, check them. Otherwise, you might get support from your hosting company.

I would recommend you to try some of these things:

  1. Try cleaning the browser's cache. If you have already visited the page, it is possible for the cache to contain information that doesn’t match the current version of the website and so blocks the connection setup, making the ERR_CONNECTION_RESET message appear.

  2. Add the following to your settings:

    memory_limit = 1024M

    max_input_vars = 2000

    upload_max_filesize = 300M

    post_max_size = 300M

    max_execution_time = 990

  3. Try setting the following input in your form:

  4. In your processing script, increase the session timeout:

    set_time_limit(200);

  5. You might need to tune up the SSL buffer size in your apache config file.

    SSLRenegBufferSize 10486000

The name and location of the conf file is different depending on distributions.

In Debian you find the conf file in /etc/apache2/sites-available/default-ssl.conf

  1. A few times it is mod_security module which prevents post of large data approximately 171 KB. Try adding/modifying the following in mod_security.conf

    SecRequestBodyNoFilesLimit 10486000 SecRequestBodyInMemoryLimit 10486000

I hope something might work out!

like image 122
Vikas Yadav Avatar answered Sep 30 '22 20:09

Vikas Yadav