# Guidelines for detecting call abnormalities

During a call, if you encounter problems such as "cannot initiate a call," "exceptionally exits after the call is initiated," "the receiver hangs up as soon as he answers," and "exceptionally quits a call", you can check this article.

There are two roles in a call: "the caller" (or "the callee," the caller") and "receipt" (or called) .Typically, we can divide a VoIP call between hardware and Weixin Mini Program into four stages: **, [[Join]], [[Wait]], and [[CALL]].Different stages may have different types of problems. When screening, it is necessary to first determine which stages are abnormal based on performance and further analyse according to the guidelines for specific stages.

It is recommended to use plug-in 2.3.2 and above.

# 1. Launch phase

Initiation phase refers to calling the plug-ininitByCallerinterface or Linux SDKwx_voip_session_callStage of creating a VoIP room.During this phase, the WeChat background performs a series of pre-call checking operations, including but not limited to:

  • Effectiveness of voipToken.
  • Whether there is an authorization relationship between the user and the device.
  • Weixin Mini Program Whether the traffic packet has a margin, or whether the device is bound to a valid license.

After checking the call, the WeChat background will push a call reminder to the receiver.

If a failure occurs in the launch phase, the interface returns errCode . Developers can determine the cause of the problem based on the instructions in the plug-in documentation . There are the following types of common errors.

# (1) User Unauthorized Device (errCode: 9)

Device and WeChat user calls, must be authorized, the specific process, please refer to "User Authorization Device" document .

Common situations where this error occurs are:

  • Not used wx.requestDeviceVoIP Authorization has been requested from the user, or the user has refused authorization after the request;
  • The user had previously authorized but subsequently revoked the authorization;
  • The user removed Weixin Mini Program from recent usage. All authorization records between the user and the Mini Program are erased at this time;
  • The incoming openId is not intended to be dialed to the user, for example: the authorized parent, here the incoming openId of the child.

In the case of the use of equipment groups, the following are also common:

  • The user has authorized Device Group A, but the device is not added to Device Group A or has been removeIotGroupDevice Interface removal;
  • User authorizes device group A, but device is used addIotGroupDevice (force_add = true)Forced transfer to another device group B also causes the device to be removed from device group A.

Optimization recommendations

It is recommended to use the authorization status query interface to determine whether the user and the device / device group directly have an authorization relationship.

  • Please call WeChat in advance. wx.getDeviceVoIPList Query the list of authorized devices of the user to determine that the device has been authorized to initiate a call again, otherwise the user should be requested to reauthorize;
  • Before the device initiates the call, it is recommended to call the plug-in in advancegetIotBindContactListThe interface determines whether there is an authorization relationship between the device and the user and initiates the call once there is, otherwise it should prompt the user to reauthorize;

For device groups, you can use getIotGroupInfo to query the list of devices in the device group.

# (2) Device calling cell phone WeChat voipToken error (errCode: 13)

For devices using device authentication SDK registered (at this timevopTokentransmitted to the SDK) [[]] obtaineddeviceToken), often the following situations occur:

  • DeviceTokenexpired.deviceTokenhas a certain validity, it needs to be updated regularly, and it will fail if it gets too long.
  • NovoipTokenfield was passed in or a null character string was passed in.This only applies to devices registered using the WMPF registerMiniProgramDevice interface.

For devices registered with WMPF , there may be the following situations:

  • The device was previously registered using the Device Authentication SDK and was not re-registered using WMPF's registerMiniProgramDevice interface.
  • WMPF below 1.2.0, or plug-in version below 2.3.0.

# 2. The "caller" accession stage

After successfully creating a VoIP room, the "dialing party" will directly join the room, and the interface will display "Connecting..." The length of accession is generally related to the current network state.

Upon successful joining, the caller triggers thejoinedRoomByCallerevent.

# (1) Before the device can dial successfully, suddenly began to continue to fail, need to restart WMPF to recover

It is probably a bug in the lower version of Android WMPF, please upgrade to > = 2.0 to solve.If similar issues are still found in the new version, please refer to section 8 for feedback.

In this case the developer may receive thejoinFailCallerevent, errMsg contains theAlready in room or joining, you can try to restart WMPF.

# (2) The card always appears "Connected" (card at this stage), cannot join the room, and the call is suddenly ended

It may be that poor network conditions cause the joining to be too slow, at which point the call may end because the receiver waits longer, triggeringabortVoipandendVoipevents.

# (3) Exit the call directly without joining the room

Common causes include:

  • Weixin Mini Program Error calling plug-inforceHangUpVoip Theinterface hangs up the call, triggering thecancelVoipevent and theendVoipevent (Toast says, "The call has been closed by the Mini Program").
    • A previous inspection encountered a portion of Weixin Mini Program that sets a timer to set the maximum duration of a call. After the call is finished, in some cases the timer is not cleaned up, causing the call to hang up at random during a subsequent call.
    • We recommend limiting the call time by listening tocallingevents and judging keepTime. does not recommend using a timer .
  • If the joining room fails due to network timeout or other exceptions, the caller receives thejoinFailCallerevent, and the errMsg and message can be obtained from the data field to analyze the cause of the error.

# 3. The caller's waiting stage

After the "caller" joins the room successfully, if the "receiver" has not entered the room, the "caller" will enter the wait state. At this point, the interface display changes from "in connection..." to "waiting for the other party to answer..."

Normally, at this stage the following actions will result in the call ending directly:

  • "Dialing party" users click the hang up button, will triggercancelVoipandendVoipevents;
  • The receiver's timeout``andendVoipevents are triggered when the receiver is overtime (currently 60s);
  • Weixin Mini Program Call plug-inforceHangUpVoipinterface hangs up the call, triggeringcancelVoipevents andendVoipevents.

# (1) Exit directly without being connected

Common causes include:

  • Weixin Mini Program Error calling plug-inforceHangUpVoipTheinterface hangs up the call, triggering thecancelVoipevent and theendVoipevent (Toast says, "The call has been closed by the Mini Program").(Common causes and 2 (3))
  • Interruption of a call due to network timeout or other exceptions on the device-side triggersabortVoipandendVoipevents, which can be referenced to section 8 feedback;

# 4. The "receiver" accession (receiver) stage

After the receiver receives the call reminder and clicks the receiver button, the receiver joins the call room and the interface displays "Connected...." The length of accession is generally related to the current network state.

  • If the receiver device is making another call at this time, it is determined to be occupied, and the caller receives thebusyevent and theendVoipevent;
  • If the receiver clicks the refuse button at this time, therejectVoipevent andendVoipevent are received;
  • (VoIP plug-in < version 2.3.2) The user performs the lock screen,Exiting WeChat or exiting Weixin Mini Program is also considered a denial, receivingrejectVoipevents andendVoipevents;

# (1) The call is not connected when the call is answered, but the call ends directly

Common causes include:

  • The call was answered later, at which point the call had already ended some time ago (possibly due to a message delay).
  • The "caller" just hung up the call or ended the call because of a timeout.
  • If the joining room fails due to network timeout or other exceptions, the receiver receives thejoinFailListenerevent, and the errMsg and message objects can be obtained from the data field to analyze the cause of the error.
  • At the time of receipt, the "caller" had exited the room because of an exception during the joining and waiting phase, which caused the call to end.
  • The user was in the middle of a system call or another VoIP call within WeChat at the time of the answer, which prevented the user from joining a new call again.

# (2) Before the user has chosen to answer or hang up, the call ends with a message that the call is rejected

(VoIP plug-in < version 2.3.2) The user performs the lock screen,Exiting WeChat or exiting Weixin Mini Program is also considered a denial, receivingrejectVoipevents andendVoipevents;

# 5. The "receiver" waiting phase

After the receiver joins the room successfully, if the caller has not entered the room, the receiver will enter the wait state. At this time, the interface shows from "connection..." to "waiting for the caller to join the call...."

At this stage, the following actions will result in the call ending directly:

  • The "Answer" user clicks the Hang Up button, triggeringrejectVoipandendVoipevents;
  • Weixin Mini Program Call plug-inforceHangUpVoipinterface hangs up the call, triggeringrejectVoipevents andendVoipevents.

# (1) After receiving the call, the call never begins, or waits a while before the call ends automatically

Common causes include:

  • "Dialing Party" fails to join successfully after timeout, which triggersabortVoipandendVoipevents;
  • Weixin Mini Program Error calling plug-inforceHangUpVoip Theinterface hangs up the call, triggering therejectVoipevent and theendVoipevent (Toast says, "The call has been closed by the Mini Program").

# 6. The call phase

When both parties to the call have successfully joined the room, the call begins until one of them finishes the call.

Normally, the end of a call is triggered by the "receiver" or "caller" user clicking the hang button or by the Weixin Mini Program calling plug-inforceHangUpVoipinterface.ThehangUpVoipevent andendVoipevent that will be said at this time;

The duration of the call only includes the "call phase." The charge is also charged according to the duration of "call stages." If the call is not connected, the charge is not charged.

# (1) When the user does not click to hang up, the call ends itself

This could be due to the following:

  • Weixin Mini Program Call plug-inforceHangUpVoip Theinterface hangs the call, triggering thehangUpVoipevent and theendVoipevent (Toast says, "The call has been closed by the Mini Program");
  • The receiver or caller unexpectedly exits, such as Weixin Mini Program being killed, network outage, etc. The other party triggersabortVoipandendVoipevents;
  • If another exception occurs during a call between the receiver or the caller, the exception will triggerabortVoipandendVoipevents. Refer to section 8 for feedback;

# 7. About call reminders

Please refer to "Call Alert Exception Troubleshooting Guide"

In other cases, please refer to section 8 for feedback.

# 8. Still unresolved.

If you still can't determine the cause, you can post a link to our analysis in the WeChat open community "hardware services" section .

If a post is posted in a different section, it may be fed back to other teams and cannot be processed in a timely manner. Please repost in the Hardware Services section.

Please provide the following in the post

  • (Android) WMPF version number: such as v1.2.0 / v2.0.0
  • (Linux) SDK version number: such as 0xD5000088
  • VoIP plugin version number: such as v2.3.0
  • Weixin Mini Program appId: wxabcdefhigklmnopq
  • Identify the information for a call (two to one)
    1. The roomId returned by the call plug-in and the date the call took place.
    2. Information for at least one party (device SN or WeChat user openId / WeChat ID) and the exact point at which the call started (the more precise the better).

If necessary, we may also contact you for additional device or mobile WeChat side logs as follows:

Device-side logs

adb pull /storage/emulated/0/Android/data/com.tencent.wmpf/files/xlog

And send us the entire log folderxlog.

Mobile phone WeChat end log

WeChat Guest House "I" - > "Settings" - > "Help & Feedback" - > "Upper Right Wrench 🔧 > > "Upload Logs" > Select "Logs of the Day of the Exception" to upload and provide the time and WeChat account .