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

scan出现公众号暂时无法服务的消息 #436

Closed
boy1583 opened this issue Jun 2, 2016 · 14 comments
Closed

scan出现公众号暂时无法服务的消息 #436

boy1583 opened this issue Jun 2, 2016 · 14 comments

Comments

@boy1583
Copy link

boy1583 commented Jun 2, 2016

我用的环境

PHP 版本:7
overtrue/wechat 版本:当前版本

问题及现象

处理scan事件时候会先出一行公众号暂时无法服务,之后能正常处理事件逻辑,通过event分支判断scan,查看log也没发现错误。必要时回复的也是空字符串,不知道哪里问题。

@overtrue
Copy link
Collaborator

overtrue commented Jun 2, 2016

@dxywx 代码呢?

@boy1583
Copy link
Author

boy1583 commented Jun 2, 2016

snip20160602_4

snip20160602_5

@boy1583
Copy link
Author

boy1583 commented Jun 2, 2016

@overtrue 代码如上

@overtrue
Copy link
Collaborator

overtrue commented Jun 2, 2016

@dxywx 日志里的:Server response created: 这里如果有XML结构 如果有正常的XML结构,你看看从请求到达一直到这条日志出现花了多久(日志前面有时间,对比一下就知道)如果大于 5s, 则可能是你的业务逻辑太复杂导致超时所致。

@boy1583
Copy link
Author

boy1583 commented Jun 2, 2016

我刚刚看了一下,从接受消息到返回只需1s时间,对于scan事件直接返回null或者‘success’或者空字符串仍然有问题,但是text消息接收和回复就不存在问题。

snip20160602_7

@overtrue
Copy link
Collaborator

overtrue commented Jun 2, 2016

@dxywx 不需要你返回任何东西。。。 SDK 自己处理,除非你要回复消息。

@boy1583
Copy link
Author

boy1583 commented Jun 16, 2016

我排查了很久,发现微信在推送scan事件时候之前可能会调用一下服务器url,我这个url在浏览器get直接访问的时候会报错(图如下)。通过微信给我反馈的错误通知,服务器响应了一个错误页面。我觉得是不是这个状态码造成了这个“暂时无法服务”的提示?

直接访问错误如下:

snip20160616_8

请问这个controller配置之后直接访问就是会报错吗?

controller配置如下:

public function development(){
        $app = app('wechat');
        $app->server->setMessageHandler(function ($message) {
            switch ($message->MsgType) {
                case 'event':
                    return $this->eventHandler($message);
                    break;
                case 'text':
                    return $this->textHandler($message);
                    break;
                case 'image':
                    # 图片消息...
                    return null;
                    break;
                case 'voice':
                    # 语音消息...
                    return null;
                    break;
                case 'video':
                    # 视频消息...
                    return null;
                    break;
                case 'location':
                    # 坐标消息...
                    return null;
                    break;
                case 'link':
                    # 链接消息...
                    return null;
                    break;
                // ... 其它消息
                default:
                    return null;
                    break;
            }
        });
        return $app->server->serve();
    }

@samplecmsv1
Copy link

samplecmsv1 commented Jun 16, 2016

遇到同样的问题。

 function index(){
    $options = [

        'app_id'    => $this->config['app_id'],
        'secret'    => $this->config['secret'],
        'token'     => $this->config['token'],
        'debug'     => true,
        'log' => [
            'level' => 'debug',
            'file'  => RUNTIME_PATH.'/easywechat.log',
        ],

    ];


    $app = new Application($options);
    $server = $app->server;

    $server->setMessageHandler(function ($message) {
        return "您好!欢迎关注我!";
    });


    $server->serve()->send();


}

日志里面没有显示错误

[2016-06-16 19:03:43] easywechat.DEBUG: Current config: {"app_id":"**_2e3f7","secret":"**_d436f","token":"wstaichi","debug":true,"log":{"level":"debug","file":"/Sr/mm.asew.com/public/../runtime//easywechat.log"}} [] [2016-06-16 19:03:43] easywechat.DEBUG: Request received: {"Method":"POST","URI":"/weichat/index/index.html?signature=bb69bad62240a69b1228a4287b3e310e1650e32c×tamp=1466075023&nonce=1695624170&openid=orohDuFZmnFKHPandDiXJv4H7yeo&encrypt_type=aes&msg_signature=f3230820166883ed86127b82dede670cc1dab202","Query":"encrypt_type=aes&msg_signature=f3230820166883ed86127b82dede670cc1dab202&nonce=1695624170&openid=orohDuFZmnFKHPandDiXJv4H7yeo&signature=bb69bad62240a69b1228a4287b3e310e1650e32c×tamp=1466075023","Protocal":"HTTP/1.0","Content":"\n \n \n 1466075023\n \n \n 6296744277679679315\n \n\n"} []

@samplecmsv1
Copy link

直接按手册写出现这样的提示。是哪里写错了吗?

@overtrue
Copy link
Collaborator

@samplecms 安全模式下 AES_KEY 你填写在哪儿了?

@samplecmsv1
Copy link

要加个['aes'] 建议手册里面加一下

@overtrue
Copy link
Collaborator

@samplecms https://easywechat.org/zh-cn/docs/configuration.html 一直就写着的好吧?

@boy1583
Copy link
Author

boy1583 commented Jun 17, 2016

@overtrue controller直接get访问出错这个问题是不是一个正常情况?

@overtrue
Copy link
Collaborator

overtrue commented Jun 17, 2016

@dxywx server 端是给微信服务器访问的,不是让你用浏览器访问的。你访问的时候又没带签名没带必要的参数,必然会报错。

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

3 participants