我发现了一个奇怪的问题。这是我的php问题代码。
static function sendImgMsg($openid, $mediaid, $access)
{
$csSelf= <<<EOF
{
"touser":"$openid",
"msgtype":"image",
"image":
{
"media_id":"$mediaid"
}
EOF;
$ret = Util::postRaw('https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $access, $csSelf);
return json_decode($ret, true);
}
static function postRaw($url, $data)
{
$opts = array (
'http' => array (
'method' => 'POST',
'header'=> "Content-type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($data) . "\r\n",
'content' => $data,
'timeout' => 60
)
);
$context = stream_context_create($opts);
return file_get_contents($url, false, $context);
}
我调用sendImgMsg函数将帖子数据发送到特定服务器。有时候打电话会挂掉。最后我发现它挂在file_get_contents api中。我将展示关于file_get_contents的strace图片。
它在读取系统调用中挂起。但是fd是无阻塞的。为什么?任何建议都表示赞赏。