|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72456 Buffer output in stream_socket_client
Submitted: 2016-06-20 09:23 UTC Modified: 2021-06-13 04:22 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: piotroo89 at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: OpenSSL related
PHP Version: 5.6.22 OS: Debian
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-06-20 09:23 UTC] piotroo89 at gmail dot com
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://';
$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);

fwrite($stream, "ehlo []\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});

Expected result:
220 ESMTP IdeaSmtpServer v0.80.2 ready. Hello [], pleased to meet you
250 HELP

Actual result:
220 ESMTP IdeaSmtpServer v0.80.2 ready.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-05-31 14:40 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-05-31 14:40 UTC]
Is this still an issue with any of the actively supported PHP

[1] <>
 [2021-06-13 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 03:01:29 2024 UTC