Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

HTTPS Connection halts when the request is too large #10

Closed
pwhelan opened this issue Jun 9, 2016 · 8 comments
Closed

HTTPS Connection halts when the request is too large #10

pwhelan opened this issue Jun 9, 2016 · 8 comments
Assignees

Comments

@pwhelan
Copy link

pwhelan commented Jun 9, 2016

When sending a large file via multipart/form-data using HTTPS the connection stalls. I am able to reproduce this consistently with php 5.6 and PHP 7 (albeit both have a different limit).

This may or may not be a problem in the underlying reactphp/socket-client or PHP ssl streams.

And here an example to test:

<?php

require_once 'vendor/autoload.php';

use \WyriHaximus\React as ReactHttp;
use React\EventLoop\Factory as LoopFactory;


$loop = LoopFactory::create();
$handler = new ReactHttp\GuzzlePsr7\HttpClientAdapter($loop);
$client = new GuzzleHttp\Client([
    'handler'   => \GuzzleHttp\HandlerStack::create($handler)
]);

// PHP 5.6 works for me until the last number is 86.
// PHP 7.x works for me until the last number is 88
$AS = str_repeat("A", 28462 + 90);
print "MD5SUM = ".md5($AS)."\n";

$client->requestAsync(
    "POST", 
    "https://skizzordz.exis.cl/test-upload.php",
    [
        'multipart' => [
            [   
                "name" => "file", 
                "contents" => $AS,
                "filename" => "A.txt"
            ]
        ]
    ])
    ->then(function($response) {
        print "RESPONSE = ".$response->getStatusCode()."\n";
        print "BODY = ".$response->getBody()."\n";
        die();
    })
    ->otherwise(function(Exception $error) {
        print("ERROR: " . $error->getMessage(). "\n");
        die();
    });

while(1) $loop->run();
@WyriHaximus WyriHaximus self-assigned this Jun 9, 2016
@pwhelan
Copy link
Author

pwhelan commented Jun 21, 2016

I managed to test directly with reactphp/http-client. It also seems to max out at 130064 (130065 bytes triggers the problem). If it helps at all I've been listening to drain events and only one is fired when the size of the request is too great.

@WyriHaximus
Copy link
Owner

Cheers that will help narrow it down in the end. I'll have to do some testing myself. Out of interest, does it matter if you POST to site A or B or is the behavior consistent for both?

@pwhelan
Copy link
Author

pwhelan commented Jun 21, 2016

I have only one test site ATM. I haven't reproduced the specifics, but the same issue happens with other public sites. I'm pretty convinced the magic number is extremely volatile.

@pwhelan
Copy link
Author

pwhelan commented Jun 30, 2016

This may have to do with the fact that reactphp/http-client does not set any specific length for requests, ie: no Transfer-Encoding: chunked or Content-Length header.

@WyriHaximus
Copy link
Owner

Interesting, aren't those headers set from guzzle? I'll look into it during the weekend 👍

@pwhelan
Copy link
Author

pwhelan commented Jul 1, 2016

I thought so too but apparently not from what I saw, at least in a simple POST call I tried. I'll add test code later.

@WyriHaximus
Copy link
Owner

It is something I can add when missing from the adapter, it should be added honestly when known.

@WyriHaximus
Copy link
Owner

Closing this issue for no activity thus assuming it has been resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants