skip to Main Content

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},

7

Answers


  1. 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!

    Login or Signup to reply.
  2. I had the same problem. I used the resumable file upload method where if the internet is disconnected and reconnects back then the upload resumes from the same progress.

    Check out the library https://packagist.org/packages/pion/laravel-chunk-upload

    1. Installation

    composer require pion/laravel-chunk-upload

    1. Add service provider

    PionLaravelChunkUploadProvidersChunkUploadServiceProvider::class

    1. Publish the config

    php artisan vendor:publish --provider="PionLaravelChunkUploadProvidersChunkUploadServiceProvider"

    Login or Signup to reply.
  3. In my opinion it maybe relative to one of them:

    About apache config (/etc/httpd2/conf ou /etc/apache2/conf):

    Timeout 300
    max_execution_time = 300
    

    About php config (‘php.ini’):

    upload_max_filesize = 2000M
    post_max_size = 2000M
    max_input_time = 300
    memory_limit = 3092M
    max_execution_time = 300
    

    About PostgreSQL config (execute this request):

    SET statement_timeout TO 0;
    

    About proxy, (or apache mod_proxy), it maybe also be due to proxy timeout configuration

    Login or Signup to reply.
  4. I went through a similar problem, in my case it was related to mod_reqtimeout by adding:

    RequestReadTimeout header=20-40, MinRate=500 body=20, MinRate=500
    

    to httpd.conf did the trick!
    You can check the documentation here.

    Hope it helps!

    Login or Signup to reply.
  5. Incase anybody else runs into this – there is also a problem with this relating to PHP-FPM. If you dont set "ProxyTimeout" in your httpd.conf – PHP-FPM uses a default timeout of one minute. It took me several hours to figure out the problem as I initially was thinking of all the normal settings like everyone else.

    Login or Signup to reply.
  6. in case anyone has the same issue, the problem I encountered is that the http request has to go through proxy sever and waf, small files upload is ok, but with large files the tcp connection automatically closed, how to validate:

    simply change your hosts setting point the domain to the web server ip address (or you may use firefox with no-proxy if there is no waf), if your problem gone then it’s the caused by the proxy or the waf in between your web server and the browser

    Login or Signup to reply.
  7. Connection-Reset occurs when php process dies without proper error message.

    Changing oracle client version from 19 to 12c and then appropriately configuring in php.ini solved the connection reset issue for our team.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search