Packet Loss Detected While Receiving Fax

I want to send and receive faxes using Asterisk.

Here are the steps I followed to set up Asterisk:

  1. Installed spandsp using:
    sudo yum install spandsp-devel
  2. Loaded the modules res_fax.so and res_fax_spandsp.so.
  3. Enabled fax_detect in pjsip.conf for the incoming context (fax_detect=yes).

My Dialplan
[from-twilio]
exten => fax,1,NoOp(Detected fax, hooray!)
same => n,ReceiveFAX(/var/spool/asterisk/fax/${UNIQUEID}.tif)
exten => _+X.,1,Verbose(Call from ${CALLERID(num)} to ${EXTEN})
same => n,Answer()
same => n,Ringing()
same => n,Wait(5) ; Wait for 5 seconds before hanging up
same => n,MusicOnHold(default)

Steps I followed to receive a fax:

  1. Sent a fax using Fax Plus to a number connected to the Asterisk trunk.
    Sending a text fax from Fax Plus works fine.
    However, when sending a PDF:
    In some cases, the packets are completely lost, and the .tif file is not created.
    In other cases, some pages are received, but:
    Text is mostly correct (but not perfect).
    Lines, shapes, and images are blurry or have missing parts.

Could you please help me resolve this issue?

Most likely you have network quality problems, in which case you need to reduce competing traffic, and/or choose a better ISP (although it might be endemic to your country).

Unlike the ATM packet networks that were used for voice, before VoIP, IP networks are not designed to give 100% guaranteed bandwidth to voice traffic. Normal packet networks are statistical. To get reliable transmission, they rely on protocols, like TCP, with retransmissions, but VoIP doesn’t use TCP, as speech would need to be delayed by the time needed to detect loss and make multiple retransmission attempts.

I’m not sure about T.38(?), but I don’t think you are using that.

Using a codec other than a G.711 one (alaw or ulaw) anywhere on the path, would also break fax over VoIP, but I think it would break it more than you describe.