-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when sending large messages over secure HTTPS with older PHP versions #60
Comments
ping @clue, could this possibly be in the SSL part of react/socket-client? |
This also happens at the socket-client level, this is an example (without actually parsing the response to exit cleanly): <?php
require_once 'vendor/autoload.php';
$url = "https://example.com";
$mp = new p3k\Multipart;
$mp->addPart('field', ''value');
$mp->addFile('photo', 'small-98kb.jpeg'', 'image/jpeg');
$loop = React\EventLoop\Factory::create();
$dnsFactory = new React\Dns\Resolver\Factory();
$dns = $dnsFactory->createCached('192.168.2.1', $loop);
$tcpConnector = new React\SocketClient\TcpConnector($loop);
$dnsConnector = new React\SocketClient\DnsConnector($tcpConnector, $dns);
$connector = new React\SocketClient\SecureConnector($dnsConnector, $loop, ['verify_peer' => false]);
$loop->nextTick(function() use ($connector, $url, $mp) {
$urlparts = parse_url($url);
$connector->create($urlparts['host'], 443)
->then(function (React\Stream\Stream $stream) use ($mp, $urlparts) {
$stream->write(
"POST {$urlparts['path']} HTTP/1.0\r\n" .
"Host: {$urlparts['host']}\r\n" .
"Content-Type: ".$mp->contentType()."\r\n" .
"Content-Length: ".strlen($mp->data())."\r\n" .
"Connection: close\r\n" .
"\r\n" .
$mp->data()
);
$stream->on('data', function($data) {
print "DATA = \n{$data}\n";
});
$stream->on('close', function() {
print "DONE\n";
});
//$stream->end();
});
});
while (1) $loop->run(); |
I also tested it with a small file and it worked perfectly. |
Thanks for letting us know, but from the details you've posted, the problem appears to be a bit unclear to me. Perhaps you can elaborate: What exactly is hanging here, what is the expected behavior and how does the observed behavior differ? There are many different possible sources of problems, perhaps this helps pinpointing this. Thanks! Could we perhaps be running into HTTP's keepalive connection timeouts here? |
Ping @pwhelan, and new info on this on? |
I fixed it by using by own external micro service in golang to upload files via https. As far as I can tell no one else has followed up with the different issues to finally fix this. From what I can tell it seems to be a problem either in PHP itself or in the way it is handled by react socket client. |
Please provide us with some more details so we can look into this (see above). So far, nobody has managed to run into the issue you're seeing, so I'm not sure there's a problem in any of the mentioned components in the first place. |
We still need some more information / confirmation here, but I suppose this may be related to reactphp/stream#64, which indicates this is a general issues with sending large chunks over a TLS connection. |
We have managed to reproduce and pin point this to a bug in PHP that has recently been fixed in 7.1.4 and 7.0.18. We're planning to provide a work around for this for affected versions via reactphp/socket#105 👍 |
When sending large contents via POST, specifically images (~90kb+) the connection simply hangs. I have already filed the same bug in for the WyriHaximus guzzle adapter here: WyriHaximus/react-guzzle-psr7#10.
Here is some short example code:
You will need a URL to POST to as well as an image file to send. Both should not be hard to get a hold of to test this.
The text was updated successfully, but these errors were encountered: