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

该公众号提供服务出现故障,请稍后重试 #3312

Open
1137525818 opened this issue Jun 17, 2024 · 5 comments
Open

该公众号提供服务出现故障,请稍后重试 #3312

1137525818 opened this issue Jun 17, 2024 · 5 comments

Comments

@1137525818
Copy link

提问前,请确保阅读过项目首页说明以及wiki开发文档相关内容,尤其是常见问题部分。完成内容后,请务必移除包括本句在内的无用内容,以免影响阅读,否则直接关闭,谢谢合作~

另外如果确认属于bug,而且已明确如何修复,请参考贡献指南直接提交PR,省的浪费时间在这里描述问题,非常感谢配合

简要描述

对接公众号品台能力,自动回复总是出现 提供服务故障

模块版本情况

  • WxJava 模块名: weixin-java-mp
  • WxJava 版本号:4.6.0

详细描述

回调代码
public ResponseEntity post(final String appid, final HttpServletRequest request, final String requestBody) {
String encType = request.getParameter("encrypt_type");
String nonce = request.getParameter("nonce");
String timestamp = request.getParameter("timestamp");
String msgSignature = request.getParameter("msg_signature");
String signature = request.getParameter("signature");
String openid = request.getParameter("openid");
log.info("接收微信请求:[openid=[{}], [openid=[{}],[signature=[{}], encType=[{}], msgSignature=[{}],"
+ " timestamp=[{}], nonce=[{}], requestBody=[{}] ",
appid, openid, signature, encType, msgSignature, timestamp, nonce, requestBody);

if (!this.wxMpService.switchover(appid)) {
  throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
}

if (!wxMpService.checkSignature(timestamp, nonce, signature)) {
  throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
}

// 这里异步发送客服消息
return ResponseEntity.ok("");
}

配置信息

public WxMpMessageRouter messageRouter(final WxMpService wxMpService) {
final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);

// 记录所有事件的日志 (异步执行)
newRouter.rule().handler(logHandler).next();

// 自定义菜单事件
newRouter.rule().msgType(EVENT).event(WxConsts.EventType.CLICK).handler(menuHandler).end();

// 关注事件,扫码事件::没有关注
newRouter.rule().msgType(EVENT).event(SUBSCRIBE).handler(subscribeHandler).end();

// 关键词回复,无关键词回复
newRouter.rule().msgType(WxConsts.MassMsgType.TEXT).handler(msgTextHandler).end();

// 扫码事件::已经关注
newRouter.rule().msgType(EVENT).event(WxConsts.EventType.SCAN).handler(scanHandler).end();
return newRouter;

}

@ylwind
Copy link

ylwind commented Jun 20, 2024

能否贴一下本地的日志呢?

@1137525818
Copy link
Author

回调处理地址就直接返回
public ResponseEntity post(final String appid, final HttpServletRequest request, final String requestBody) {
return ResponseEntity.ok("");
}

// 事件处理, 直接就WxMpXmlOutMessage返回null,我是异步发送的客服消息
public class MenuHandler extends AbstractHandler {
@OverRide
public WxMpXmlOutMessage handle(final WxMpXmlMessage wxMessage,
final Map<String, Object> context,
final WxMpService wxMpService,
final WxSessionManager sessionManager) {
String appId = getAppId(context);
String eventKey = wxMessage.getEventKey();
log.info("MenuHandler菜单事件, appId: {}, eventKey: {}", appId, eventKey);
if (StringUtils.isNotEmpty(wxMessage.getEventKey())) {
// 发送客服消息
wxMpService.getKefuService().sendKefuMessage()
}
return null;
}
}

@ylwind
Copy link

ylwind commented Jun 20, 2024

https://github.com/Wechat-Group/WxJava/wiki/MP_%E5%BE%AE%E4%BF%A1%E6%B6%88%E6%81%AF%E8%B7%AF%E7%94%B1%E5%99%A8

按照此文档,需要返回return ResponseEntity.ok("");,麻烦尝试修改后进行测试

@ylwind
Copy link

ylwind commented Jun 20, 2024

其次建议异步调用客服消息,否则可能因为调用客服消息响应时间过长导致公众号无法及时收到相应

@1137525818
Copy link
Author

WxMpMessageHandler 我返回的都是 null,都是异步处理
只是WxMpMessageInterceptor这个没有实现, (这个有影响吗)
WxMpMessageHandler不同事件类型也发送消息了,就是接收到消息后,还有一个
该公众号提供服务出现故障,请稍后重试 信息

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

2 participants