perl lwp 超时问题

lwp 超时问题:

jrhmpt01:/root/async# cat a1.pl 
use  LWP::UserAgent;
use utf8;
use DBI;
use POSIX;
use Data::Dumper;
use HTML::TreeBuilder;
  use HTML::TreeBuilder::XPath;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent("Mozilla/8.0");
#my $response = $ua->get('http://data.10jqka.com.cn/financial/yjyg/date/2016-03-31/board/ALL/field/enddate/order/desc/page/1/ajax/1/');
#my $response = $ua->get('http://data.10jqka.com.cn/financial/yjyg/');


my $response = $ua->get('http://120.55.11x.6:3000/api/env?ip=192.168.32.101');
if ($response->is_success) {
print   $response->decoded_content;  # or whatever
}
else
{print   $response->decoded_content; };


设置超时时间为 $ua->timeout(10);


结果如下:
jrhmpt01:/root/async# time perl a1.pl
500 read timeout

real	0m10.192s
user	0m0.169s
sys	0m0.016s

服务端在10秒内没返回,就超时



转载于:https://www.cnblogs.com/zhaoyangjian724/p/6200173.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值