Description of WeChat development protocol

Source: Internet
Author: User
A published message corresponds to a unique ID (as long as the message is unique in one direction, the server may judge the root ID for repeated receipt). The message retransmission mechanism ensures a limited number of retries. if the retry fails, the user is prompted, if the message is sent successfully, the client determines that the message is sent successfully only when it receives the confirmation message. A new SyncKey may not be generated when messages are sent. 1. A published message corresponds to a unique ID (as long as the message is unique in one direction, the server may judge the root ID for repeated receipt). The message retransmission mechanism ensures a limited number of retries. if the retry fails, the user is prompted, if the message is sent successfully, the client determines that the message is sent successfully only when it receives the confirmation message. A new SyncKey may not be generated when messages are sent.

2. based on the status message synchronization mechanism of the version number (SynKey), the incremental and ordered transmission needs to come to fruition. Long connection notification/short connection acquisition, confirmation, and so on. The interaction method is simple, ensuring reliable message spectrum and accurate arrival.

3. both the client and server store the message ID processing records to avoid being repeatedly consumed by the client to obtain the latest message. However, the server does not consider the message to be consumed if it is not confirmed. The client will obtain the message again next time and query whether the message has been processed. I guess based on some phenomena.

4. in general, the protocol is cross-platform (both TCP and HTPP can be presented in a unified manner), and is synchronized through a "handshake", which is reliable and can be well supported by any platform.

5. the minimum protocol cost is 16 bytes. most of the time, several message packets are combined for batch transmission. The protocol is not concise, it is not the most traffic-saving, but very successful.

6. if the server detects some uncertainties, it may lead to the use of secure sockets layer SSL protocol for conventional TCP persistent connection transmission. The transient connection has not changed.

7. message sending method

Send a message to the server through the established TCP persistent connection channel, and then accept the confirmation information to generate an interaction.

When reading information, the partner will also receive notifications from the server to generate an interaction.

It can be determined that the message is sent through the TCP persistent connection mode, because it does not affect its status data and should not be exchanged with SyncKey.

In a low-speed network, you will probably see a message sending prompt, which is a message re-sending mechanism.

If the network is poor, the client may experience a red exclamation mark indicating that the message fails to be sent.

If a message has been sent to the server but has not received a confirmation message, the client displays a red exclamation mark and resends the message. the server processes the message as a duplicate message and returns the message for confirmation.

The uploaded image is divided into several parts according to the image size (about K is divided into parts). at the same time, the client initiates several POST requests. after each upload is successful, the server is probably merged into a complete image, and a thumbnail is returned, which is displayed in the APP chat window. The APP is sent to the server as a regular text message

When uploading audio, the TCP channel is used separately. a two-second recording audio is recorded on the client, which is divided into two transmission parts, one of which is about KB. The server responds to a Data Notification and confirms receipt. Data is transmitted three times in total.

The audio and plain text information are consistent. they are sent by the client over TCP persistent connections and confirmed by the server.

The above is the detailed description of the development protocol. For more information, see other related articles on php Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.