📖 SIP Status Codes & Call Disconnect Reference
This document provides a comprehensive reference of SIP response codes, standardized SDK cause strings, error messages, and best practices for handling call disconnect events in the Pitel VoIP Flutter SDK.
🔍 Overview
When an active or outgoing call ends, the SDK emits a PitelCallDisconnectedEvent (or updates PitelCallStateChangedEvent) through the PitelVoipClient.instance.events stream. The event contains three diagnostic fields:
statusCode(int): The raw SIP status code returned by the PBX / SIP server (e.g.,486,404,200).cause(String?): A standardized SDK cause identifier normalized across both iOS and Android (e.g.,'USER_BUSY','UNALLOCATED_NUMBER').reason(String?): The SIP phrase or reason string provided by the PBX (e.g.,'Busy Here','Not Found').
📊 Complete SIP Status Codes Table
| SIP Code | SDK Cause (event.cause) | Standard English Description | Meaning / Context | Normal vs Error |
|---|---|---|---|---|
| 200 | NORMAL_CLEARING | (Call ended normally) | Call connected and ended naturally after conversation. | Normal (null) |
| 487 | ORIGINATOR_CANCEL | (Request Terminated) | Either caller or callee hung up before the call was answered. | Normal (null) |
| 486 / 600 | USER_BUSY | User is currently busy. | The destination is occupied on another call or rejected the call. | Error / Busy |
| 480 | NO_USER_RESPONSE | Destination is temporarily unavailable or did not answer. | Ringing timed out without an answer, or extension is temporarily offline. | Error / Timeout |
| 404 | UNALLOCATED_NUMBER | The dialed phone number does not exist. | Dialed extension or phone number is invalid / not found on PBX. | Error / Not Found |
| 401 / 402 / 403 / 407 / 603 / 608 | CALL_REJECTED | Call was rejected or account lacks outbound calling permission. | PBX rejected the call due to permissions, SIP auth failure, or insufficient funds. | Error / Rejected |
| 408 / 504 | RECOVERY_ON_TIMER_EXPIRE | Request timed out waiting for PBX response. | Network timeout waiting for SIP response from PBX server or gateway. | Error / Timeout |
| 484 | INVALID_NUMBER_FORMAT | Invalid phone number format. | Number format is incomplete or missing necessary area/country prefix. | Error / Invalid |
| 488 / 606 | INCOMPATIBLE_DESTINATION | Incompatible destination. | Codec mismatch or media negotiation failed between endpoints. | Error / Codec |
| 485 / 604 | NO_ROUTE_DESTINATION | No route to destination. | PBX cannot find a routing path to reach the requested destination. | Error / Routing |
| 502 | NETWORK_OUT_OF_ORDER | Network or gateway is out of order. | Telephony gateway or intermediate carrier link is down. | Error / Gateway |
| 400 / 481 / 500 / 503 | NORMAL_TEMPORARY_FAILURE | Temporary PBX server or network failure. | PBX server encountered an internal error, maintenance, or overload. | Error / Server |
💻 Handling Disconnect Events in Flutter
Approach 1: Using the Built-in SDK Helper (getPitelCallErrorMessage)
The SDK provides getPitelCallErrorMessage({event}) out of the box. It automatically ignores normal terminations (200 OK, 487 Request Terminated) by returning null, and formats failure messages with status codes for errors:
import 'package:flutter_pitel_voip_v2/flutter_pitel_voip_v2.dart';
PitelVoipClient.instance.events.listen((event) {
if (event is PitelCallDisconnectedEvent) {
// Automatically returns null for normal hangup, or formatted string for failures
final String? errorMessage = getPitelCallErrorMessage(event: event);
if (errorMessage != null) {
// Example output: "486 - User is currently busy."
// or "404 - The dialed phone number does not exist."
showErrorDialog(errorMessage);
} else {
print('Call ended normally.');
}
}
});
Approach 2: Custom Localized Messages via event.cause
If your application requires custom UI messages or multi-language localization, use a switch statement on event.cause:
import 'package:flutter_pitel_voip_v2/flutter_pitel_voip_v2.dart';
PitelVoipClient.instance.events.listen((event) {
if (event is PitelCallDisconnectedEvent) {
final message = switch (event.cause) {
'USER_BUSY' => 'The line is currently busy.',
'NO_USER_RESPONSE' => 'The recipient did not answer.',
'UNALLOCATED_NUMBER' => 'The dialed number does not exist.',
'CALL_REJECTED' => 'Call was rejected or account lacks permissions.',
'RECOVERY_ON_TIMER_EXPIRE' || 'NORMAL_TEMPORARY_FAILURE' =>
'Server connection timed out. Please try again later.',
'NETWORK_OUT_OF_ORDER' => 'Telephony gateway is currently unavailable.',
'INVALID_NUMBER_FORMAT' => 'Invalid phone number format.',
'ORIGINATOR_CANCEL' || 'NORMAL_CLEARING' => null, // Normal hangup
_ => event.statusCode >= 400 ? 'Call ended with error code: ${event.statusCode}' : null,
};
if (message != null) {
showToast(message);
}
}
});