Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cURL error 56: SSLRead() return error -9806 #473

Closed
hbliang opened this issue Jul 30, 2016 · 11 comments
Closed

cURL error 56: SSLRead() return error -9806 #473

hbliang opened this issue Jul 30, 2016 · 11 comments

Comments

@hbliang
Copy link

hbliang commented Jul 30, 2016

我用的环境

PHP 版本:5.6.18
overtrue/wechat 版本:3.1

492a3e20-bc25-408f-9427-dcbee1a2f9d7

## 问题及现象

$material->uploadArticleImage($filename);
使用上面的方法,经常性报错**(cURL error 56: SSLRead() return error -9806 )**,偶尔上传成功。

easywechat upload fail:

image

easywechat upload success:

image

我利用原生的curl上传,没有任何问题。甚是奇怪。

        $media = new \CURLFile($filename);
        $url = 'api.wechat.....';

        $curl = curl_init();

        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER,['Content-Type: multipart/form-data']);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, ['media' => $media]);

        $r = curl_exec($curl);

        curl_close($curl);

另外,$material->uploadImage($filename);此方法也ok,没任何问题。

@hbliang
Copy link
Author

hbliang commented Jul 30, 2016

另外,我dump了\GuzzleHttp\Handler\CurlFactory.php->public static function finish()->$easy->response
image
发现header参数为空,是否有影响呢?

@hbliang
Copy link
Author

hbliang commented Jul 30, 2016

Logs

easywechat.log:

[2016-07-31 01:48:21] easywechat.DEBUG: Current config: {"debug":true,"app_id":"***c5cbe","secret":"***8454b","token":"weixin","log":{"level":"debug","file":"/Users/Ben/project/xiyanghui/wechat_middleware/app/../var/logs/easywechat.log"}} []
[2016-07-31 01:48:21] easywechat.DEBUG: Client Request: {"url":"https://api.weixin.qq.com/cgi-bin/media/uploadimg","method":"POST","options":{"timeout":5,"query":[],"multipart":[{"name":"media","contents":"[resource] (stream)"},{"name":"type","contents":"news_image"}]}} []
[2016-07-31 01:48:21] easywechat.DEBUG: Request: POST https://api.weixin.qq.com/cgi-bin/media/uploadimg {"timeout":5,"handler":{},"synchronous":true,"allow_redirects":{"max":5,"protocols":["http","https"],"strict":false,"referer":false,"track_redirects":false},"http_errors":true,"decode_content":true,"verify":true,"cookies":false} [] []
[2016-07-31 01:48:21] easywechat.DEBUG: Request headers:{"Content-Length":["13612"],"User-Agent":["GuzzleHttp\/6.2.1 curl\/7.43.0 PHP\/5.6.18"],"Content-Type":["multipart\/form-data; boundary=579ce86572a44"],"Host":["api.weixin.qq.com"]} [] []

symfyon.logs:

[2016-07-31 01:48:21] request.INFO: Matched route "{route}". {"route":"homepage","route_parameters":{"_controller":"AppBundle\\Controller\\DefaultController::indexAction","_route":"homepage"},"request_uri":"http://localhost:8000/","method":"GET"} []
[2016-07-31 01:48:21] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2016-07-31 01:48:22] request.CRITICAL: Uncaught PHP Exception GuzzleHttp\Exception\RequestException: "cURL error 56: SSLRead() return error -9806 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)" at /Users/Ben/project/xiyanghui/wechat_middleware/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php line 187 {"exception":"[object] (GuzzleHttp\\Exception\\RequestException(code: 0): cURL error 56: SSLRead() return error -9806 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) at /Users/Ben/project/xiyanghui/wechat_middleware/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187)"} []
[2016-07-31 01:48:23] request.INFO: Matched route "{route}". {"route":"_wdt","route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"86796d","_route":"_wdt"},"request_uri":"http://localhost:8000/_wdt/86796d","method":"GET"} []

@tianyong90
Copy link
Contributor

@hbliang
Copy link
Author

hbliang commented Jul 31, 2016

已经参考过了。。。问题还是没有解决
image

@ac1982
Copy link
Contributor

ac1982 commented Jul 31, 2016

你这个情况是单次偶发,还是在循环中偶发?

@hbliang
Copy link
Author

hbliang commented Jul 31, 2016

@ac1982
我发现是上传这一张图片的时候,经常性报错,偶尔可以上传成功。
甚是奇怪。
你试试用这图片上传。
图片如下。
default

@ac1982
Copy link
Contributor

ac1982 commented Jul 31, 2016

现在云服务商都有图片甄别功能,比如敏感信息或者之类的。
你这句是提示类信息,我个人觉得根本不需要图片去实现它,一段html不是更好吗?
上传错误的问题,我这里并没有重现。

@hbliang
Copy link
Author

hbliang commented Jul 31, 2016

@ac1982
刚测试了一下。上传了一张写着“色情”两字的图片,也报同样的错误。估计微信那边会过滤掉一些有敏感信息的照片。
另外,关于一段html确实是更好。。。但是公司的编辑不会写html。。。

@ac1982
Copy link
Contributor

ac1982 commented Jul 31, 2016

他们不会写html,你就给他们个示例嘛,这样也省去你很多烦恼不是。这个Issue只能帮你到这里了。

@hbliang
Copy link
Author

hbliang commented Aug 1, 2016

@ac1982 thx啦

@overtrue
Copy link
Collaborator

overtrue commented Aug 1, 2016

@ac1982 @li7721994 感谢,已经在相关文档上添加说明 EasyWeChat/docs@06f2994

@overtrue overtrue closed this as completed Aug 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants