我使用的是一个连接到代理并通过代理发送数据的socks5 php库。当我向http服务器发出单个请求时,库可以工作,但当我在接收空字符串中执行第二个请求时,在第三个请求中接收到一个错误。
10053主机中的软件中止了已建立的连接。
我不明白为什么会这样,我看了一下socks5服务器的RFC和维基百科,我认为所有的连接都是正确的。但还是没有得到第二反应。
库代码是一个文件,我从这里获得它,Socks5Socket
我的代码是下一个
set_time_limit(100);
error_reporting ( E_ALL );
require_once "Socks5Socket.php";
$s = new \Socks5Socket\Client();
$s->configureProxy(array(
'hostname' => '162.144.56.44',
'port' => 60088
));
$s->connect('en.wikipedia.org', 80);
$request = "GET /wiki/HTTP_persistent_connection HTTP/1.1\r\n".
"Host: en.wikipedia.org\r\nConnection: Keep-Alive\r\n\r\n";
$s->send($request);
$response = $s->readAll();
//At this point all OK
$request2 = "GET /wiki/No-till_farming HTTP/1.1\r\n".
"Host: en.wikipedia.org\r\nConnection: Keep-Alive\r\n\r\n";
$s->send($request2);
// Empty string here, no error
$response2 = $s->readAll();
$s->send($request2);
// Errno 10053
$response3 = $s->readAll();
file_put_contents("response.txt",$response2);
$response = substr($response,strpos($response,"»")+1);
//echo $response;
echo "<br><br>".substr($response,strpos($response,"\r\n\r\n")+1);发布于 2015-02-18 09:00:53
好的,问题是http服务器在我做任何其他事情之前关闭了我的连接。我试过使用SMTP服务器,连接不再关闭。
https://stackoverflow.com/questions/28569177
复制相似问题