Rearrange WeChat push event messages to find logical problems in WeChat backend services

 

1. Discovery

I have discussed how to filter the event messages and ordinary messages pushed by WeChat. Today, I checked the online WeChat interface push event log and found that there are duplicate messages, which is basically impossible when the system is not under high load.

 

Look again at the re-arrangement suggestions for the development documents of the WeChat public account

WeChat official account development document wrote
When users follow and unfollow the official account, WeChat will push the event to the URL filled in by the developer. It is convenient for developers to send welcome messages to users or to unbind accounts.

If the WeChat server does not receive a response within five seconds, the connection will be disconnected, and the request will be re-initialized for a total of three retries.

Regarding the retrying of messages, it is recommended to use FromUserName + CreateTime.

If the server cannot guarantee to process and reply within five seconds, it can directly reply with an empty string, and the WeChat server will not do anything to this, and will not initiate a retry.

 

The content of the repeated message printed by the system is (the asterisk is a mosaic):

{FromUserName=oIh7bvukj**********ZvcAIDug, EventKey=https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2ce10f858dd547eb&redirect_uri=http%3A%2F%2Fwechat.hitumedia.com%2Fhituwechat%2FshakeshakePage.action&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect, Event=VIEW, CreateTime=1452742113, MenuId=401850190, ToUserName=gh_********df, MsgType=event}

 

2. Check

This is an event message, I used FromUserName + CreateTime  to deduplicate, if the message is repeated, there must be the same FromUserName + CreateTime  record in the database, check the event log data table, the result is clear at a glance:



 

3. Analyze the reasons

Our WeChat official account has enabled the function of obtaining the user's geographic location. After opening WeChat, the user clicks the menu to enter the page. At this time, the WeChat background pushes us the user's geographic location event message and the user 's click menu event message . The CreateTime  and The openid is the same, which leads to being identified as a duplicate message by our system. The reordering method recommended by the document filters out the legitimate data, which should be due to the insufficient consideration of the WeChat backend service.

 

4. Solve

When the message is reloaded, the Event field can also be added to it.

For details, please refer to my previous article " WeChat Push Message Rearrangement Solution "

 

Corrections are welcome, thanks for your attention.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327036940&siteId=291194637