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

发送客服消息使用外部API获得access_token不缓存 #216

Open
chijincn opened this issue Sep 5, 2019 · 4 comments
Open

发送客服消息使用外部API获得access_token不缓存 #216

chijincn opened this issue Sep 5, 2019 · 4 comments

Comments

@chijincn
Copy link

chijincn commented Sep 5, 2019

现象描述

使用本地直接获取access_token会缓存,但使用外部access_token时依然不缓存。

如果使用了外部token再切换回本地直接获取方式进行发送,此时获取到的access_token也不再缓存。

【本次测试仅修改过 bug fix:修复微信小程序相关消息accessToken缓存机制问题 修改的4个文件,未测试9月5日最新版本】

环境信息

JDK1.8

重现步骤

  • 步骤1,设置 -> 微信公众号->填写appid及appscreate
  • 步骤2,新建消息、获取openid等操作
  • 步骤3,发送消息,查看日志 access_token缓存
  • 步骤4,设置 -> 微信公众号->勾选使用外部accesstoken ...
  • 步骤4,发送消息,查看日志 使用了不同的access_token
  • 步骤5,设置 -> 微信公众号->去掉勾选使用外部accesstoken ...
  • 步骤4,发送消息,查看日志 使用了不同的access_token

重启软件后可恢复。

报错信息

【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_wuJjQhzN-YJ4Jnj9RdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iLrADAtL8dsHftkSkbKoh-slgDoQTD7PM4u8kOVgMjCBS-aDDnBxJx-fukpmEJBxoXbJvDae4VBAmr9XN-eazBZVTVeAJARPR
【请求参数】:{"touser":"okmq0t5eg-23MbwOxmdwq1ANv07A","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [FV3y3a06532066]"}
11:04:14.562 [pool-5-thread-3] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [FV3y3a06532066]"}
11:04:14.563 [pool-5-thread-3] WARN c.f.tool.push.util.ConsoleUtil :30 - T-2已处理完第2-3条的数据
11:04:14.582 [pool-5-thread-4] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_qjmuOQ3kyFq3cXYvRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iL-GPc14YzfnS4CW5WAIBLc_YyeWGJddQyxAdC8ef3C-EBed7wCUnUu4yqmk_GMCe2RuUKepeuf8VLrkkiWAy0PFIQeAJAZCK
【请求参数】:{"touser":"okmq0t-YpNTT7KYLXbXnVEL8oJfE","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [aNUQbA06534107]"}
11:04:14.583 [pool-5-thread-4] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [aNUQbA06534107]"}
11:04:14.584 [pool-5-thread-4] WARN c.f.tool.push.util.ConsoleUtil :30 - T-3已处理完第3-4条的数据
11:04:14.749 [pool-5-thread-2] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_XBl4v3miyUCnjBIyRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iKPntNjF_eFRrVnEnLfmIB21XJMGZpyALQJufmxCR4rxwt3pe3qweqkllNQhFqKFoU_adKDoHUrYJaHzDazspUQLOIeAJAEHB
【请求参数】:{"touser":"okmq0t27Nvzp1nploE7oFynpEqMs","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [G2fm7a06544121]"}
11:04:14.749 [pool-5-thread-2] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [G2fm7a06544121]"}
11:04:14.750 [pool-5-thread-2] WARN c.f.tool.push.util.ConsoleUtil :30 - T-1已处理完第1-2条的数据
11:04:14.783 [pool-5-thread-6] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_9nhOmg5-hQQT1R4RRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iJjo9baQKuAS9ahFVpwhib83LhySsiA2AWQtpW5TG8s01nMPppYpu_shdMfaR-kkeTaBf85u17W4WWRdQmL6M3kKTJeAJARAQ
【请求参数】:{"touser":"okmq0t2jha0MpsC6ahaMmjdIAuyw","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [1k06543937]"}
11:04:14.783 [pool-5-thread-6] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [1k06543937]"}
11:04:14.784 [pool-5-thread-6] WARN c.f.tool.push.util.ConsoleUtil :30 - T-5已处理完第5-6条的数据
11:04:14.833 [pool-5-thread-7] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_RZ9dmc8FSi10mKSkRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iLXrh61JFWGbMj_LeUoT-_TgiiFe3G1dnZz5v1xKbcP_UdxtAcecqpIRBzcxniwMzEmC8-4IHTntbFuXZM5hmT7PETeAJAHWL
【请求参数】:{"touser":"okmq0t-lPwrsdJLzl3-83vqENGdY","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [ts6m606543948]"}
11:04:14.834 [pool-5-thread-7] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [ts6m606543948]"}
11:04:14.835 [pool-5-thread-7] WARN c.f.tool.push.util.ConsoleUtil :30 - T-6已处理完第6-7条的数据
11:04:14.914 [pool-5-thread-11] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_VvrFVug63OyvzmiCRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iLSAkY0857HVprFdcquyv-0wIOnI0YOCHBRQTAzh19lp8WqziZqdcYrKxtu73kNsJZvyLujTO2SAUhvUwxCnUSMWSQeAJAPLJ
【请求参数】:{"touser":"okmq0twwypbEw9yS-td7s5lra2vU","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [n28tAa06544102]"}
11:04:14.914 [pool-5-thread-11] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [n28tAa06544102]"}
11:04:14.915 [pool-5-thread-11] WARN c.f.tool.push.util.ConsoleUtil :30 - T-10已处理完第10-11条的数据
11:04:14.956 [pool-5-thread-12] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_Ou03ITRNVy-NArJlRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iJtq1CvwmMt4NzXaJm_lpc_2ZPVUzsLPld-S5uXSeDPkXlkGT62Gzp2WP6T4Pc8u5At0KorpGyeIclK5TeEyRoJRZPeAJAFND
【请求参数】:{"touser":"okmq0t4DDN81IaohuuwholtlJlgQ","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [AV49Va06543951]"}
11:04:14.956 [pool-5-thread-12] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [AV49Va06543951]"}
11:04:14.957 [pool-5-thread-12] WARN c.f.tool.push.util.ConsoleUtil :30 - T-11已处理完第11-12条的数据
11:04:15.012 [pool-5-thread-5] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_82AtxoAalY0rhSNMRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iK7fG1PgGU5v1-5TckIX_uiwPiI1o7cS3p6sXpQHpP9qan-ZbuPsP52dzIxeQ0vU72P0TBIVXa7LZsIKIQvbN1tHBGeAJAZTY
【请求参数】:{"touser":"okmq0txGYoLcy_aN-29QWD0hdXVE","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [QJ__6a06544122]"}
11:04:15.012 [pool-5-thread-5] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [QJ__6a06544122]"}
11:04:15.013 [pool-5-thread-5] WARN c.f.tool.push.util.ConsoleUtil :30 - T-4已处理完第4-5条的数据
11:04:15.047 [pool-5-thread-9] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_84zWY4vggIhFe56yRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iL4HXSdTR3dOMKWWJz55uYvTldPI-4iBClsi8UDkjagRdyLv6v9Dm8uf-pe4gLSEBbQgxNoqt_OvhLc0TBy0V0NAOQeAJAFTV
【请求参数】:{"touser":"okmq0t84B1vMqmjAWnkb7scT-QA8","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [JTkpja06544120]"}
11:04:15.047 [pool-5-thread-9] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [JTkpja06544120]"}
11:04:15.049 [pool-5-thread-9] WARN c.f.tool.push.util.ConsoleUtil :30 - T-8已处理完第8-9条的数据
11:04:15.058 [pool-5-thread-13] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException:
11:04:15.059 [pool-5-thread-13] WARN c.f.tool.push.util.ConsoleUtil :30 - T-12已处理完第12-13条的数据
11:04:15.060 [pool-5-thread-8] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException:
11:04:15.061 [pool-5-thread-8] WARN c.f.tool.push.util.ConsoleUtil :30 - T-7已处理完第7-8条的数据
11:04:15.062 [pool-5-thread-10] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException:
11:04:15.063 [pool-5-thread-10] WARN c.f.tool.push.util.ConsoleUtil :30 - T-9已处理完第9-10条的数据
11:04:15.128 [pool-5-thread-14] ERROR c.f.tool.push.util.WeWxMpServiceImpl :324 -
【请求地址】: https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=25_g33Cy1e-wNMhN96iRdJ81D3eeRbT1DU2rq0iimqvNsHH3g9em3MBFBYW7iId4ncPkrm6U2k4r4MFUr2RK5mpLO3h4UUU0COE9vnJXyP5UihBqY7G3ihQstelImub1L2kYsDYrkd_MHmUotOeTEVeAJABMD
【请求参数】:{"touser":"okmq0tyC_O2vMWvT2PzZfaVwh4Tc","msgtype":"text","text":{"content":"一条客服文本消息,<a href="https://www.baidu.com\">去百度\n\nCJNET OK"}}
【错误信息】:{"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [E2HGAA06544107]"}
11:04:15.129 [pool-5-thread-14] ERROR c.f.t.p.l.msgsender.WxKefuMsgSender :44 - me.chanjar.weixin.common.error.WxErrorException: {"errcode":45015,"errmsg":"response out of time limit or subscription is canceled hint: [E2HGAA06544107]"}

@rememberber
Copy link
Owner

@chijincn 非常感谢!使用外部accessToken确实存在问题,已经修复了,会在下一版更新,如果等不及更新,可以clone本项目在项目中运行WePush
另外,使用外部和非外部accessToken两种互相切换时会先让之前缓存的accessToken失效,这个是设计如此,是因为一些多账号切换场景需要如此,不用担心,只是两种模式切换后第一次会失效,然后后面都继续缓存

@chijincn
Copy link
Author

chijincn commented Sep 6, 2019

@chijincn 非常感谢!使用外部accessToken确实存在问题,已经修复了,会在下一版更新,如果等不及更新,可以clone本项目在项目中运行WePush
另外,使用外部和非外部accessToken两种互相切换时会先让之前缓存的accessToken失效,这个是设计如此,是因为一些多账号切换场景需要如此,不用担心,只是两种模式切换后第一次会失效,然后后面都继续缓存

你好,请问是只修改了src/main/java/com/fangxuele/tool/push/util/WeWxMpServiceImpl.java这个文件吗,好像问题依旧。

@rememberber
Copy link
Owner

@chijincn 非常感谢!使用外部accessToken确实存在问题,已经修复了,会在下一版更新,如果等不及更新,可以clone本项目在项目中运行WePush
另外,使用外部和非外部accessToken两种互相切换时会先让之前缓存的accessToken失效,这个是设计如此,是因为一些多账号切换场景需要如此,不用担心,只是两种模式切换后第一次会失效,然后后面都继续缓存

你好,请问是只修改了src/main/java/com/fangxuele/tool/push/util/WeWxMpServiceImpl.java这个文件吗,好像问题依旧。

@chijincn 我测试没问题,测试过程如下:
第一步:
在获取accessToken(后面简称ACT)的工具类的返回前增加打印ACT到控制台的代码:
图像 044

图像 045
第二步:
配置服务号,发送客服消息,观察控制台打印:

图像 049

第三步:
再次发送客服消息,观察控制台打印:
图像 050
没有变化,说明缓存了

第四步:
将该ACT通过外部api接口返回:
图像 051
配置为使用外部ACT
图像 052
再次发送客服消息:
外部项目收到了请求:
图像 053
WePush控制台打印:
图像 054
再次发送客服消息,外部项目没有收到请求:
图像 055
观察WePush控制台,证明使用了缓存:
图像 056

@chijincn
Copy link
Author

@rememberber 你好,我刚刚测试了最新的版本。

发现如果此前使用过本地直接获取ACT的设置发送消息,再更改为使用外部AccessToken,此时ACT是不缓存的。我注意到之前你说过这是一种技术上的设计,我觉得这样设计可能会让不熟悉本软件的人误操作。希望可以考虑优化一下。

软件在其它情况下表现正常。

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