Critical Fax Failure Issue with Asterisk 20, and Spandsp 0.0.6

Hi,
I have a critical issue.

I’m using fax over Twilio SIP trunk with Asterisk and Spandsp. However, our customers’ faxes are failing more often than they succeed — the success rate is less than 50%. I’m unable to reproduce the issue myself.

I’m using pjsip.conf, and here is the configuration:

[sipcore]
type=endpoint
transport=transport-udp
disallow=all
allow=ulaw
allow=alaw
allow=g729
context=internal
direct_media=no
100rel=no
outbound_proxy=sip:xxxxxxxxxxxxxxxxxxxxxxx:4060\;lr
fax_detect=yes

Here are some relevant fax logs showing the errors:
[2025-07-11 12:56:14.194] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Training succeeded (-4) in state 7
[2025-07-11 12:56:14.194] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Stop T2 (82400 remaining)
[2025-07-11 12:56:14.194] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Switching from V.17 + V.21 to V.17 (-13.55dBm0)
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Carrier down (-1) in state 7
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Trainability (TCF) test result - 21876 total bits. longest run of zeros was 21600
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_C_NON_ECM_RX to T30_PHASE_B_TX
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 0
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 4
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from state 7 to 8
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: CFR with final frame tag
[2025-07-11 12:56:15.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: ff 13 84
[2025-07-11 12:56:16.775] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_B_TX, state 8
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_B_TX, state 8
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from state 8 to 10
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_B_TX to T30_PHASE_C_NON_ECM_RX
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 0
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 7
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 0
[2025-07-11 12:56:16.855] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Start T2
[2025-07-11 12:56:16.874] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier down (-1) in state 10
[2025-07-11 12:56:17.494] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Carrier up (-2) in state 10
[2025-07-11 12:56:17.494] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier up (-2) in state 10
[2025-07-11 12:56:17.654] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Training failed (-5) in state 10
[2025-07-11 12:56:17.694] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Carrier down (-1) in state 10
[2025-07-11 12:56:17.694] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Status changing to 'Carrier lost during fax receive'
[2025-07-11 12:56:17.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Carrier up (-2) in state 10
[2025-07-11 12:56:17.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier down (-1) in state 10
[2025-07-11 12:56:17.714] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier up (-2) in state 10
[2025-07-11 12:56:17.774] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Training failed (-5) in state 10
[2025-07-11 12:56:18.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:19.414] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:19.834] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:24.074] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:25.634] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:26.274] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:28.094] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:28.241] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 10
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 T2 expired in phase T30_PHASE_C_NON_ECM_RX, state 10
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Status changing to 'Timer T2 expired while waiting for fax page'
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Start receiving document
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Flushing queued phase T30_PHASE_B_TX
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from state 10 to 17
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 DIS:
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Store and forward Internet fax (T.37): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Real-time Internet fax (T.38): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= 3G mobile network: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= V.8 capabilities: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Preferred octets: 256 octets
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Ready to transmit a fax document (polling): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..1.= Can receive fax: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..10 11..= Supported data signalling rates: V.27 ter, V.29, and V.17
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .1.. ....= R8x7.7lines/mm and/or 200x200pels/25.4mm: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= 2-D coding: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..00= Recording width: 215mm +- 1%
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 10..= Recording length: Unlimited
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .111 ....= Receiver's minimum scan line time: 0ms at 3.85 l/mm; T7.7 = T3.85
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Compressed/uncompressed mode: Compressed
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Error correction mode (ECM): Non-ECM
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= T.6 coding: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= "Field not valid" supported: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Multiple selective polling: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Polled sub-address: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= T.43 coding: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...0 ....= Plane interleave: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Voice coding with 32kbit/s ADPCM (Rec. G.726): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Reserved for the use of extended voice coding set: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...1= R8x15.4lines/mm: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= 300x300pels/25.4mm: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= R16x15.4lines/mm and/or 400x400pels/25.4mm: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= Inch-based resolution preferred: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...1 ....= Metric-based resolution preferred: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Minimum scan line time for higher resolutions: T15.4 = T7.7
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Selective polling: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Sub-addressing: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Password: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Ready to transmit a data file (polling): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...0 ....= Binary file transfer (BFT): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Document transfer mode (DTM): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Electronic data interchange (EDI): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Basic transfer mode (BTM): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Ready to transfer a character or mixed mode document (polling): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= Character mode: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Mixed mode (Annex E/T.4): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Processable mode 26 (Rec. T.505): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Digital network capability: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Duplex capability: Half only
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= JPEG coding: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...0 ....= Full colour mode: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= 12bits/pel component: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= No subsampling (1:1:1): Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Custom illuminant: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Custom gamut range: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 1...= North American Letter (215.9mm x 279.4mm): Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...1 ....= North American Legal (215.9mm x 355.6mm): Set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Single-progression sequential coding (Rec. T.85) basic: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Single-progression sequential coding (Rec. T.85) optional L0: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 0... ....= Extension indicator: Not set
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: DIS with final frame tag
[2025-07-11 12:56:28.854] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: ff 13 80 00 ee f8 80 80 91 80 80 80 18
[2025-07-11 12:56:29.094] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:29.274] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:29.594] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:31.214] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:31.894] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:32.974] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:33.074] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:33.394] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:34.274] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:35.894] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:35.934] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Abort (-8) in state 17
[2025-07-11 12:56:36.754] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Non-ECM signal status is Carrier down (-1) in state 17
[2025-07-11 12:56:36.754] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Status changing to 'Carrier lost during fax receive'
[2025-07-11 12:56:36.754] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_C_NON_ECM_RX to T30_PHASE_B_TX
[2025-07-11 12:56:36.754] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 0
[2025-07-11 12:56:36.754] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 4
[2025-07-11 12:56:36.754] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier down (-1) in state 17
[2025-07-11 12:56:38.075] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_B_TX, state 17
[2025-07-11 12:56:38.155] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_B_TX, state 17
[2025-07-11 12:56:38.155] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_B_TX to T30_PHASE_B_RX
[2025-07-11 12:56:38.155] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 4
[2025-07-11 12:56:38.155] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 0
[2025-07-11 12:56:38.155] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Start T4
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 T4 expired in phase T30_PHASE_B_RX, state 17
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Retry number 1
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_B_RX to T30_PHASE_B_TX
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 0
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 4
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 DIS:
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Store and forward Internet fax (T.37): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Real-time Internet fax (T.38): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= 3G mobile network: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= V.8 capabilities: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Preferred octets: 256 octets
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Ready to transmit a fax document (polling): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..1.= Can receive fax: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..10 11..= Supported data signalling rates: V.27 ter, V.29, and V.17
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .1.. ....= R8x7.7lines/mm and/or 200x200pels/25.4mm: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= 2-D coding: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..00= Recording width: 215mm +- 1%
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 10..= Recording length: Unlimited
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .111 ....= Receiver's minimum scan line time: 0ms at 3.85 l/mm; T7.7 = T3.85
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Compressed/uncompressed mode: Compressed
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Error correction mode (ECM): Non-ECM
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= T.6 coding: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= "Field not valid" supported: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Multiple selective polling: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Polled sub-address: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= T.43 coding: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...0 ....= Plane interleave: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Voice coding with 32kbit/s ADPCM (Rec. G.726): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Reserved for the use of extended voice coding set: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...1= R8x15.4lines/mm: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= 300x300pels/25.4mm: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= R16x15.4lines/mm and/or 400x400pels/25.4mm: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= Inch-based resolution preferred: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...1 ....= Metric-based resolution preferred: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Minimum scan line time for higher resolutions: T15.4 = T7.7
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Selective polling: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Sub-addressing: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Password: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Ready to transmit a data file (polling): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...0 ....= Binary file transfer (BFT): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Document transfer mode (DTM): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Electronic data interchange (EDI): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Basic transfer mode (BTM): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Ready to transfer a character or mixed mode document (polling): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= Character mode: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Mixed mode (Annex E/T.4): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= Processable mode 26 (Rec. T.505): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Digital network capability: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Duplex capability: Half only
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 0...= JPEG coding: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...0 ....= Full colour mode: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= 12bits/pel component: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 1... ....= Extension indicator: Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ...0= No subsampling (1:1:1): Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... ..0.= Custom illuminant: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... .0..= Custom gamut range: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .... 1...= North American Letter (215.9mm x 279.4mm): Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ...1 ....= North American Legal (215.9mm x 355.6mm): Set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 ..0. ....= Single-progression sequential coding (Rec. T.85) basic: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 .0.. ....= Single-progression sequential coding (Rec. T.85) optional L0: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 0... ....= Extension indicator: Not set
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: DIS with final frame tag
[2025-07-11 12:56:41.614] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: ff 13 80 00 ee f8 80 80 91 80 80 80 18
[2025-07-11 12:56:42.935] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_B_TX, state 17
[2025-07-11 12:56:43.015] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_B_TX, state 17
[2025-07-11 12:56:43.015] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_B_TX to T30_PHASE_B_RX
[2025-07-11 12:56:43.015] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 4
[2025-07-11 12:56:43.015] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 0
[2025-07-11 12:56:43.015] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Start T4
[2025-07-11 12:56:43.734] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier up (-2) in state 17
[2025-07-11 12:56:43.954] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Framing OK (-6) in state 17
[2025-07-11 12:56:43.954] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Start T4A
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Stop T4A (16320 remaining)
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Rx: EOP with final frame tag
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Rx: ff 13 2f
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Rx final frame in state 17
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Unexpected EOP frame in state 17
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from state 17 to 3
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: DCN with final frame tag
[2025-07-11 12:56:44.914] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Tx: ff 13 fa
[2025-07-11 12:56:44.954] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 HDLC signal status is Carrier down (-1) in state 3
[2025-07-11 12:56:44.954] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_B_RX to T30_PHASE_D_TX
[2025-07-11 12:56:44.954] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 0
[2025-07-11 12:56:44.954] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 4
[2025-07-11 12:56:46.035] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_D_TX, state 3
[2025-07-11 12:56:46.115] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Send complete in phase T30_PHASE_D_TX, state 3
[2025-07-11 12:56:46.115] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Starting final pause before disconnecting
[2025-07-11 12:56:46.124] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_D_TX to T30_PHASE_E
[2025-07-11 12:56:46.124] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 0
[2025-07-11 12:56:46.124] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 1
[2025-07-11 12:56:46.124] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from state 3 to 2
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from state 2 to 30
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Changing from phase T30_PHASE_E to T30_PHASE_CALL_FINISHED
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set rx type 9
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX FAX exchange complete
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX Set tx type 9
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW FAX FAX exchange complete
[2025-07-11 12:56:46.983] FAX[1083590][C-000001e8] res_fax.c: FLOW T.30 Call completed

Environment:

  • Twilio SIP Trunk
  • Asterisk v20
  • Spandsp v0.0.6

I tried by enabling and disabling ECM(Error Correction Mode).

Could you please help me to troubleshoot and resolve this issue?

That is not compatible with the use of modems. Maybe you can guarantee that it will not be negotiated when fax is involved, but it woujld be safer not to allow it.

Thanks for the reply. We checked the audio codec in the SDP and confirmed that PCMU/8000 and PCMA/8000 is present.

Hi Akhil,

That is because FAXing over VoIP doesn’t work.

FAXing over VoIP requires that the fax machines on BOTH sides support so-called “Internet Faxing” that is the T.38 “internet aware faxing protocol”

Most newer FAX machines do support T.38 but older ones don’t.

Your customers probably have newer fax machines and when they connect with another newer fax machine, they negotiate T.38 and the fax goes through. But when they connect to an older machine they try to use g.711 and that protocol is destroyed by VoIP.

Removing the SIP allow = g729 isn’t going to do anything. For starters, your customers FAX machines are all undoubtedly plugged into VoIP to POTS gateways and pretty much all of those on the market only support g.711 So when their FAX machine makes a call, it’s going to negotiate either alaw or ulaw depending on what your Twilio, your POTS gateway and your Asterisk system do. It’s certainly not going to negotiate g.729 and then have either Twilio or your Asterisk system transcode it back to G.711

At the other end, the call is likely going to route through the PSTN to the destination FAX machine and it will be G.711 there as well. Note that within PSTN and within Twilio and within your customers VoIP network, is where codecs apply and g.711 has meaning - exiting the PSTN to the destination FAX machine it’s all analog, of course thus the codec is meaningless.

The only reliable way for your customers to send and receive FAXes with 100% reliability is for them to either get their own POTS line and plug it directly into their FAX machines - or pay an Internet Fax company that runs in the cloud with a client they run on their PC and print-to-fax. Those Internet Fax companies all have banks of faxmodems with PSTN connections because they have run into this same issue.

But T.38 only works if you are doing something like intracompany faxing where you can guarantee the fax machine, and with the advent of email, nobody does this anymore. Or, it works if you tell your customers to tell their corespondents that they need to throw away their FAX machines and buy new ones. Which is likely to go over like a lead balloon.

Ted

Fax can work over VoIP, if the latency is low enough and G.711 is used, end to end,

In most of the Western world, the PSTN is half way through switching to VoIP for its internal transport.

No, it can’t. At least, NOT the way most people doing VoIP are doing VoIP.

I know this but I’m trying to dumb things down, here, to make them understandable to the OP. But, your diving into the sewer so I’ll have to come along for the ride.

I’ll start with the difference between digital trunks and The Internet, specifically broadband.

A digital trunk is an analog POTS line converted to 64k g.711alaw or ulaw, also referred to as “narrowband voice”. It’s also known as a DS0

24 DS0’s are combined into a DS1, 28 DS1 channels are combined into a DS3, and 3 DS3’s are combined into an OC3. (OC3 is a SONET fiber standard, the others are copper standard)

The PSTN is comprised of a gigantic network of OC3s, OC12, OC48’s and so forth. However all of them can be broken down to the basic DS0 of 64kbps. All of these are “ISDN” standards.

The thing about all of these links is - they are completely lossless. They are NOT Ethernet, they are NOT CSMA (carrier sense multiple access) They are CIRCUITS they have exactly 1 beginning and 1 end. In essense, they are pipes.

There is a newer technology called Carrier Ethernet that is sort of like Ethernet but not really - because the entire circuit paradigm is superimposed on it. Meaning, that a “phone call” in the PSTN is always in that 64k pipe, that “trunk” or “line” and never loses any data. It’s lossless because it only has 1 beginning and 1 end thus nothing else on the circuit can inject packets.

This is why FAX works over a POTS line. Because FAX signals are analog but are converted at the central office to digital and put into this lossless ISDN digital pipe then presumably somewhere else they exit this go back into a POTS line and are converted back to analog and received by the destination fax machine.

Now let’s look at typical VoIP SIP trunks from a provider like Twilio SIP that the OP is using and are delivered over the general Internet. These come over the Internet via TCP/IP. There’s no guaranteed packet delivery on the Internet, there’s no guaranteed packet delivery on IP. Guaranteed packet delivery comes from TCP and the way you make a guaranteed packet delivery work on a network that does not guarantee delivery is through retransmissions. Meaning that if the IP layer loses a packet the TCP layer on top of that retransmits.

This loss takes time to detect and time to retransmit. If your circuit is lightning fast, and lightly loaded, then the retransmits are almost undetectable. These are referred to as “low latency” circuits.

But, you don’t have control over most of the circuits that your packets are traversing. If you run a traceroute you will see this at once - some “hops” have lower latency than others. This latency also varies during the day and night and it can vary from moment to moment. You can have a high latency in one of those links that lasts for 5 seconds then disappears.

Just about everyone on this forum conflates VoIP with The Internet. The OP, Akhil, isn’t talking about running a SIP trunk over some controlled latency network like an ethernet switch with 1 port in a ATA plugged into a fax and another port plugged into another ATA in another fax elsewhere. He’s talking about running a SIP trunk over the most hostile environment possible - the public Internet.

This is precisely why I state categorically that FAX does not work over VoIP. Oh sure - in the lab - when I can control latency and prioritize voice packet delivery - it works great. I can duplicate the vast PSTN with it’s controlled delivery of ISDN data with my little ethernet switch and run FAX over that. Look ma, a dancing elephant.

Now, there IS a loophole in all this. The OP can go to a telephone company, get an Internet line from that company, and then get a SIP trunk from that company. Since the Internet Service Provider in that case is also providing the SIP trunk, they can probably guarantee all their SIP packets will arrive to the customer. But, they probably aren’t going to be a lot cheaper than a POTS line.

But, what the OP is trying to do - save a few bucks on a cheap SIP trunk over the Internet and run a fax machine off that - simply will not work. Unless of course, both machines support T.38 Which is not guaranteed, and which is exactly why his clients report it’s “random” on what faxes go through and what don’t.

He needs to quit banging his head against the wall and just bite the bullet and tell his clients that they need to fork over the money for a FAX line - or, slip FAXes into the dustbin of history and use email attachments like normal people do.