Bug #72456 [NEW]: Buffer output in stream_socket_client
| From: | piotroo89 at gmail dot com | Date: | Mon, 20 Jun 2016 09:23:18 +0000 |
| Subject: | Bug #72456 [NEW]: Buffer output in stream_socket_client | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-201742@lists.php.net to get a copy of this message | ||
From: piotroo89 at gmail dot com
Operating system: Debian
PHP version: 5.6.22
Package: OpenSSL related
Bug Type: Bug
Bug description:Buffer output in stream_socket_client
Description:
------------
I have a problem with stream socket and SSL in PHP 5.6. It seems that
SSL is buffering output. In the example below "ehlo" command is ignored
(server is not responding). But when something else is sent after "ehlo"
e.g. a new line in another call to fwrite, server sends response.
I've tried using stunnel to check if it's a PHP SSL wrapper issue and
when I change $host to $host = 'localhost:110;' (my stunnel
configuration) everything works perfectly (without adding that special
fwrite method).
In PHP 5.4.45 this case work perfectly.
Test script:
---------------
$streamContext = stream_context_create();
$host = 'ssl://smtp.some.server.com:465';
$stream = stream_socket_client($host, $errno, $errstr, $timeout,
STREAM_CLIENT_CONNECT, $streamContext);
stream_set_blocking($stream, 1);
stream_set_timeout($stream, $timeout);
stream_set_write_buffer($stream, 0);
$fgets = fgets($stream);
print_r($fgets);
fwrite($stream, "ehlo [127.0.0.1]\r\n");
fwrite($stream, "\r\n"); //when I write this into socket result is OK,
without this socket seems to be buffered
$response = '';
do {
$line = fgets($stream);
$response .= $line;
} while (null !== $line && false !== $line && ' ' != $line{3});
print_r($response);
Expected result:
----------------
220 epicserver.net.pl ESMTP IdeaSmtpServer v0.80.2 ready.
250-epicserver.net.pl Hello ip-166-242.pl [94.183.162.232], pleased to
meet you
250-PIPELINING
250-ENHANCEDSTATUSCODES
250-SIZE
250-8BITMIME
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250 HELP
Actual result:
--------------
220 epicserver.net.pl ESMTP IdeaSmtpServer v0.80.2 ready.
--
Edit bug report at https://bugs.php.net/bug.php?id=72456&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72456&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72456&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72456&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72456&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72456&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72456&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72456&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72456&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72456&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72456&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72456&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72456&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72456&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72456&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72456&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72456&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72456&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72456&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72456&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72456&r=mysqlcfg