|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-29 09:30 UTC] daniel dot buschke at nextiraone dot de
Description:
------------
When trying to connect to a host via fsockopen and socksify (see dante) I get following:
PHP Warning: fsockopen(): unable to connect to 1.2.3.4:99 (Operation now in progress) in /socksify.php on line 15
But "Operation now in progress" is not an error which tolds that connect fails.
socket_create and socket_connect are working fine.
seems like #39803 but has different version. Patch of #38568 did not work
Reproduce code:
---------------
<?php
$sock = fsockopen('1.2.3.4', 99);
?>
Expected result:
----------------
$sock should be an handle which is usable with fread or sth like this
$sock !== FALSE
Actual result:
--------------
PHP Warning: fsockopen(): unable to connect to 1.2.3.4:99 (Operation now in progress) in /socksify.php on line 15
$sock === FALSE
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
<?php $sock = fsockopen('69.147.83.196', 80); ?> This one trys to connect to an IP of bugs.php.net. Remember that I run this script with socksifiy in front: socksify php -f socksify.php I'm sure it is not easy for you to reproduce this bug. So here is the whole story: I want to connect from Server A (lan) to a Server B (internet). Server A is behind a firewall which drops allmost everything. So if I want to connect to the internet I have to use SOCKS5. Therefore I have to use socksify. socks_create and socks_connect are working fine! So this is not a problem of socksify. But I can not use socks because I want to use ssh2_* buildins which are using the same core functions as fsockopen and which result in same problem.Try this (timeout included) instead: <?php $sock = fsockopen('1.2.3.4', 99, $errno, $errstr, 30); ?>webserver_dev sandbox # cat fsockopen_timeout.php <?php fsockopen('69.147.83.196', 80, $errno, $errstr, 30); echo "errno: $errno\n"; echo "errstr: $errstr\n"; ?> webserver_dev sandbox # socksify php -f fsockopen_timeout.php PHP Warning: fsockopen(): unable to connect to 69.147.83.196:80 (Operation now in progress) in /www/vhosts/dev/sandbox/fsockopen_timeout.php on line 2 errno: 115 errstr: Operation now in progress of curse it is equal to '1.2.3.4', 99here is the test script that shows that socket_create and socket_connect is working: webserver_dev sandbox # cat socks.php <?php define('TCP', 6); $sock = socket_create(AF_INET, SOCK_STREAM, TCP); socket_connect($sock, '69.147.83.196', 80); socket_send($sock, "GET /\n", strlen('GET / HTTP 1.0'), 0); echo socket_read($sock, 100); socket_close($sock); ?> webserver_dev sandbox # socksify php -f socks.php This document is located <a href="/viewvc.cgi/">here</a>.Ok, there are some things: 1. fsockopen is using a blocking socket, isn't it? 2. I told, that fsockopen is using the same functions as ssh2_*() If you want to use ssh2 functionallity you have the same problem: -------------------------------------------- webserver_dev sandbox # cat ssh.php <?php $ssh_con = ssh2_connect('84.38.64.78'); $fingerprint = ssh2_fingerprint($ssh_con, SSH2_FINGERPRINT_MD5 | SSH2_FINGERPRINT_HEX); echo $fingerprint ?> webserver_dev sandbox # socksify php -f ssh.php PHP Warning: ssh2_connect(): Unable to connect to 84.38.64.78 on port 22 in /www/vhosts/dev/sandbox/ssh.php on line 3 PHP Warning: ssh2_connect(): Unable to connect to 84.38.64.78 in /www/vhosts/dev/sandbox/ssh.php on line 3 PHP Warning: ssh2_fingerprint() expects parameter 1 to be resource, boolean given in /www/vhosts/dev/sandbox/ssh.php on line 4 -------------------------------------------- Please try this script with you own ssh server. My will drop you if you try! So, this is a bug of ssh2 from pecl, because they are using that "quick'n'dirty socket stuff"?!