Php 冻结循环卷曲,没有任何错误

Php 冻结循环卷曲,没有任何错误,php,curl,Php,Curl,请参阅此示例代码和输出。 我在windows上通过cmd运行它。 这段代码运行良好,但几天后,冻结并停止输出 您可以看到此日志的最后一行,没有任何错误或迹象 我不知道是什么原因 do { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://www.tsetmc.com/Loader.aspx?ParTree=151313&Flow=0'); curl_setopt($ch, CURLOPT_RETURN

请参阅此示例代码和输出。
我在windows上通过cmd运行它。
这段代码运行良好,但几天后,冻结并停止输出
您可以看到此日志的最后一行,没有任何错误或迹象
我不知道是什么原因

do {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://www.tsetmc.com/Loader.aspx?ParTree=151313&Flow=0');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    $headers = array();
    $headers[] = 'Connection: keep-alive';
    $headers[] = 'Cache-Control: max-age=0';
    $headers[] = 'Upgrade-Insecure-Requests: 1';
    $headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36';
    $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9';
    $headers[] = 'Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915';
    $headers[] = 'Accept-Encoding: gzip, deflate';
    $headers[] = 'Accept-Language: en-US,en;q=0.9,fa;q=0.8';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error: ' . curl_error($ch) . PHP_EOL;
    }
    if (!$result) {
        echo 'Error: No Result.' . PHP_EOL;
    }
    curl_close($ch);
    
    sleep(60);
}while(true);
输出:

*   Trying 185.117.206.245:80...
* TCP_NODELAY set
* Connected to www.tsetmc.com (185.117.206.245) port 80 (#0)
> GET /Loader.aspx?ParTree=151313&Flow=0 HTTP/1.1
Host: www.tsetmc.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,fa;q=0.8

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: public, no-cache="Set-Cookie"
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Expires: Sat, 12 Sep 2020 14:33:49 GMT
< Set-Cookie: ASP.NET_SessionId=wrqiwgu5u115153ia15ohd4a; path=/; HttpOnly; SameSite=Lax
< Date: Sat, 12 Sep 2020 14:33:40 GMT
< Content-Length: 15623
<
* Connection #0 to host www.tsetmc.com left intact

*   Trying 185.117.206.245:80...
* TCP_NODELAY set
* After 2499ms connect time, move on!
* connect to 185.117.206.245 port 80 failed: Timed out
*   Trying 185.117.204.245:80...
* TCP_NODELAY set
* Connected to www.tsetmc.com (185.117.204.245) port 80 (#0)
> GET /Loader.aspx?ParTree=151313&Flow=0 HTTP/1.1
Host: www.tsetmc.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,fa;q=0.8

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: public, no-cache="Set-Cookie"
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Expires: Sat, 12 Sep 2020 14:34:59 GMT
< Server: Microsoft-IIS/10.0
< Set-Cookie: ASP.NET_SessionId=f5qzrtaopkuhn0q3yjy5h3vx; path=/; HttpOnly; SameSite=Lax
< X-Powered-By: ASP.NET
< Date: Sat, 12 Sep 2020 14:34:51 GMT
< Content-Length: 15623
<
编辑:
我尝试了这个解决方案:
结果是:

:
:
:

2020-11-03 -  5:29:24
*   Trying 185.117.204.245:80...
* TCP_NODELAY set
* Connected to www.tsetmc.com (185.117.204.245) port 80 (#0)
> GET /Loader.aspx?ParTree=151313&Flow=0 HTTP/1.1
Host: www.tsetmc.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,fa;q=0.8

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: public, no-cache="Set-Cookie"
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Expires: Tue, 03 Nov 2020 02:03:15 GMT
< Server: Microsoft-IIS/10.0
< Set-Cookie: ASP.NET_SessionId=34cwudfw41fkvibcksu45lnt; domain=.tsetmc.com; path=/; HttpOnly; SameSite=Lax
< Date: Tue, 03 Nov 2020 02:03:06 GMT
< Content-Length: 16989
<
* Connection #0 to host www.tsetmc.com left intact

Done. (121808 B)

Pinging WIN-G2AELSC5ER9 [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
    Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

2020-11-03 -  5:29:33
*   Trying 185.117.204.245:80...
* TCP_NODELAY set
* Connected to www.tsetmc.com (185.117.204.245) port 80 (#0)
> GET /Loader.aspx?ParTree=151313&Flow=0 HTTP/1.1
Host: www.tsetmc.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,fa;q=0.8

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: public, no-cache="Set-Cookie"
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Expires: Tue, 03 Nov 2020 01:59:42 GMT
< Set-Cookie: ASP.NET_SessionId=03ymtrwh14eqgxyii1ryijvr; domain=.tsetmc.com; path=/; HttpOnly; SameSite=Lax
< Content-Security-policy: defult-Src 'self'
< X-Content-Type-Options: nosniff
< X-Farams-Options: DENY
< X-XSS-Protection:  1; mode=block
< Date: Tue, 03 Nov 2020 01:59:33 GMT
< Content-Length: 16989
<
* Connection #0 to host www.tsetmc.com left intact

Done. (121808 B)

Pinging WIN-G2AELSC5ER9 [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms
Reply from ::1: time<1ms

Ping statistics for ::1:
    Packets: Sent = 10, Received = 10, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

2020-11-03 -  5:29:43
*   Trying 185.117.204.245:80...
* TCP_NODELAY set
* Connected to www.tsetmc.com (185.117.204.245) port 80 (#0)
> GET /Loader.aspx?ParTree=151313&Flow=0 HTTP/1.1
Host: www.tsetmc.com
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,fa;q=0.8

* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: public, no-cache="Set-Cookie"
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Expires: Tue, 03 Nov 2020 02:03:50 GMT
< Server: Microsoft-IIS/10.0
< Set-Cookie: ASP.NET_SessionId=wzwab2sgb1ib5afibur0tayf; domain=.tsetmc.com; path=/; HttpOnly; SameSite=Lax
< Date: Tue, 03 Nov 2020 02:03:42 GMT
< Content-Length: 16989
<
:
:
:
2020-11-03 -  5:29:24
*正在尝试185.117.204.245:80。。。
*TCP_节点集
*连接到www.tsetmc.com(185.117.204.245)端口80(#0)
>GET/Loader.aspx?ParTree=151313&Flow=0http/1.1
主持人:www.tsetmc.com
连接:保持活力
缓存控制:最大年龄=0
升级不安全的请求:1
用户代理:Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/79.0.3945.117 Safari/537.36
接受:text/html、application/xhtml+xml、application/xml;q=0.9,图像/webp,图像/apng,*/*;q=0.8,申请/签名交换;v=b3;q=0.9
推荐人:http://www.tsetmc.com/Loader.aspx?ParTree=151915
接受编码:gzip,deflate
接受语言:en-US,en;q=0.9,fa;q=0.8
*将捆绑包标记为不支持多用途
回复:1:时间没有线索。似乎是一个无休止的循环,每天间隔1分钟,对吗

PHP可能需要更多睡眠。对不起,那个笑话

您已经写过,您可以通过cmd执行php。我理解这一点,因为您可以使用批处理文件。 因此,我为您提供了一个可能的建议/解决方案/解决方案:

  • 从php中删除循环,并在批处理文件中创建循环
batchfile.bat

    @ECHO OFF
    :loop
    echo %date:~0% - %time:~0,8%
    REM !YOUR PHP CALL HERE!
    @ping -n 60 localhost > nul
    cls
    GOTO loop
我认为您熟悉php,但这里是修改后的代码(只需在睡觉时删除):

编辑:自从我上次使用php/curl已经很久了。我记不清了,但我想是卷曲和睡眠的关系。Idk什么。请求的回应或者类似的。如果我可以问的话,你从哪里得到旋度循环的输出?无论如何,我希望我的想法是合适的


如果您想尝试一下,请不要忘记删除“REM”。

谢谢,我测试了这个,没有得到好的结果,我在问题的末尾添加了结果。5:29:24/5:29:33/5:29:43-ping实际上应该暂停一分钟,不会产生任何输出。您是如何启动批处理文件的?你有哪个Windows版本?是的,我被改成了
ping-n10localhost
,但我不认为效果不好。Windows server 2016数据中心在VPS.set
curl_setopt上运行($ch,CURLOPT_TIMEOUT,10)
再试一次,有什么区别吗?@hanshenrik这不是像这样冻结的原因,你认为我是否将超时设置为1秒,我是否应该不接收逻辑消息?
    @ECHO OFF
    :loop
    echo %date:~0% - %time:~0,8%
    REM !YOUR PHP CALL HERE!
    @ping -n 60 localhost > nul
    cls
    GOTO loop
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.tsetmc.com/Loader.aspx?ParTree=151313&Flow=0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$headers = array();
$headers[] = 'Connection: keep-alive';
$headers[] = 'Cache-Control: max-age=0';
$headers[] = 'Upgrade-Insecure-Requests: 1';
$headers[] = 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36';
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9';
$headers[] = 'Referer: http://www.tsetmc.com/Loader.aspx?ParTree=151915';
$headers[] = 'Accept-Encoding: gzip, deflate';
$headers[] = 'Accept-Language: en-US,en;q=0.9,fa;q=0.8';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch) . PHP_EOL;
}
if (!$result) {
    echo 'Error: No Result.' . PHP_EOL;
}
curl_close($ch);