-
Notifications
You must be signed in to change notification settings - Fork 24
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
Use default stream data handler #33
Conversation
I have checked this issues but none of them will resolve this "stream_get_contents" issue |
Can you post some code to reproduce the problem you have? In all our tests
if ($stream = fopen('http://www.example.com', 'r')) {
// print all the page starting at the offset 10
echo stream_get_contents($stream, -1, 10);
fclose($stream);
} The documentation and examples show |
This works fine with webserver but i have to connect to socket server which sends data all the time. So the handler will not work until connection will be closed |
Please post code to reproduce this issue. I have personally tested this code against an HTTPS server and an SSL IRC server; which does not close the connection after receiving data via |
This is my example code: $host = 'live.example.com';
$port = 1234;
$username = 'user1';
$password = '123456';
$loop = \React\EventLoop\Factory::create();
$dnsResolver = new \React\Dns\Resolver\Factory();
$dns = $dnsResolver->createCached('8.8.8.8', $loop);
$connector = new \React\SocketClient\Connector($loop, $dns);
$secureConnector = new \React\SocketClient\SecureConnector($connector, $loop);
$secureConnector->create($host, $port)->then(function (\React\Stream\Stream $stream) use ($username, $password) {
$this->log('CONNECTED');
$stream->on('data', function ($data) {
$this->log('DATA -> ' . $data);
});
$stream->on('error', function ($error) {
$this->log('ERROR');
});
$stream->on('close', function () {
$this->log('CLOSE');
});
$stream->write('<login><credential><loginname value="' . $username . '"/><password value="' . $password . '"/></credential></login>' . "\r\n\r\n");
});
$loop->run(); Result with "stream_get_contents":
Result with "fread":
One thing I have noticed is that SSL connection read is really slow.
It took 3 seconds to read this XML string. Without SSL its working fine and fast. |
I have found a solution to avoid this blocking EOF check |
Using this version: PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10) Can't say much except that I'm able to connect to the Freenode IRC network using SSL with @dercoder's patch and I'm not noticing any blocking or other abnormal behavior. |
Can you show me your code so i can test it? I am using PHP 5.6.8-1 |
Please check your Gist. Does your code work with SSL on PHP 5.5.9? |
@dercoder It does work with your patch. I haven't tested it without the patch. |
Can you please try it without Patch + SSL? |
Hm... it seems to work the same regardless of whether the patch is applied or not, from my point of view. |
So it seems to be a PHP 5.6 issue |
I don't have an environment readily available to confirm, but I should later on tonight (I'm UTC-5 at the moment). |
I wonder if this is related to reactphp/reactphp#273
|
I have PHP 5.5.20 and 5.4.6 locally to test on. 5.5.20 seems to have the same SSL fix 5.6.8 has. On 5.4.6 I can see the SSL non-draining buffer bug related to #14, #24, and #26. To re-enable that bug I have completely disabled the
I'm not sure how to specifically trigger this bug though. I use a phergie script and have seen at the React level of it where the buffer drain isn't happening. I'm still waiting on @dercoder to test the master branch, where >=5.6.8 ignores the secure wrap so always uses My concern with this PR is the following from the php.net documentation on
I don't remember the details but I recall @DaveRandom looking into the source code of both of these and |
I have tested the master branch with my script and phergie script. Its working fine now on PHP 5.6.8. |
Yes, i think you can close it |
Thanks for the confirmation! |
This SecureStream data handler uses "stream_get_contents" which will handle data only when connection has been closed. Use "fread" instead which will be used by default in "Stream" Class