file_get_contents在端口8282上不起作用 [英] file_get_contents does not work on port 8282

查看:143
本文介绍了file_get_contents在端口8282上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了以下基本脚本,这些脚本发出了基本的POST请求(在添加更多内容之后,我只是想使其工作):

I got the following basic script who make a basic POST request (I just want to make it work, after I'll add more stuff) :

#   Variables
$URL = 'http://******:8282/api/incoming_shipment/';

$postdata = http_build_query(
    array(
        'contract_id'       => 'Showcare-R124276',
        'shipment_from'     => 'Montréal',
        'shipment_to'       => 'Chicago',
        'shipping_time'     => '2012-08-16 14:51:01',
        'tracking_cie'      => 'Poste Canada',
        'tracking_type'     => 'Standard',
        'tracking_number'   => 'EP645 9834 123 9773'
    )
);

$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);

$context = stream_context_create($opts);

$result = file_get_contents($URL, FALSE, $context);

print_r($result);

结果给我:

Warning: file_get_contents(http://******:8282/api/incoming_shipment/) [function.file-get-contents]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:\Inetpub\hightechhandling\api\api_push_contract.php on line 31

Fatal error: Maximum execution time of 30 seconds exceeded in D:\Inetpub\hightechhandling\api\api_push_contract.php on line 31

但是,当我使用浏览器访问该网页时,它可以正常运行.我已经尝试过cURL和fsocketopen,但是那也没有用.有什么帮助吗?谢谢.

But When I go to the webpage with my browser, it work perfectly. I have tryed cURL and fsocketopen but that didn't work too. Any help please ? Thanks..

编辑,我添加了set_time_limit (500);,现在第二个错误当然消失了……但是第一个错误仍然存​​在.

EDIT I added set_time_limit (500); and now the second error has disapear of course... but the first still remain.

推荐答案

好,发现了问题.太愚蠢了.问题是因为发出请求的服务器(PHP文件所在的服务器)启用了防火墙,并且防火墙仅允许端口21、22、80、3306和1433进行外部请求.

Ok, found the problem. Was sooo stupid. The problem is because the server that make the request (where the PHP file is), has a firewall enabled and the firewall allow only port 21, 22, 80, 3306 and 1433 for external request.

这篇关于file_get_contents在端口8282上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆