Skip to main content

📖 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 CodeSDK Cause (event.cause)Standard English DescriptionMeaning / ContextNormal vs Error
200NORMAL_CLEARING(Call ended normally)Call connected and ended naturally after conversation.Normal (null)
487ORIGINATOR_CANCEL(Request Terminated)Either caller or callee hung up before the call was answered.Normal (null)
486 / 600USER_BUSYUser is currently busy.The destination is occupied on another call or rejected the call.Error / Busy
480NO_USER_RESPONSEDestination is temporarily unavailable or did not answer.Ringing timed out without an answer, or extension is temporarily offline.Error / Timeout
404UNALLOCATED_NUMBERThe 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 / 608CALL_REJECTEDCall was rejected or account lacks outbound calling permission.PBX rejected the call due to permissions, SIP auth failure, or insufficient funds.Error / Rejected
408 / 504RECOVERY_ON_TIMER_EXPIRERequest timed out waiting for PBX response.Network timeout waiting for SIP response from PBX server or gateway.Error / Timeout
484INVALID_NUMBER_FORMATInvalid phone number format.Number format is incomplete or missing necessary area/country prefix.Error / Invalid
488 / 606INCOMPATIBLE_DESTINATIONIncompatible destination.Codec mismatch or media negotiation failed between endpoints.Error / Codec
485 / 604NO_ROUTE_DESTINATIONNo route to destination.PBX cannot find a routing path to reach the requested destination.Error / Routing
502NETWORK_OUT_OF_ORDERNetwork or gateway is out of order.Telephony gateway or intermediate carrier link is down.Error / Gateway
400 / 481 / 500 / 503NORMAL_TEMPORARY_FAILURETemporary 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);
}
}
});