I found the issue. If I have a SINGLE TRUNK setup in PJSIP, T.38 Fax completes successfully.
Issues arise when there are MULTIPLE PJSIP trunks to the SAME PROVIDER configured (does not have to be enabled), and T.38 Negotiation will fail. This is due to the way that currently Asterisk/PJSIP will match the incoming call to the FIRST Identify section with the itsp IP. For example, if I have multiple trunks to a VOIP provider (different user credentials) defined in Freepbx 13, the resulting pjsip.identify.conf will be somewhat like the following:
Now when a fax comes thru for the fax number 3502XXXX, asterisk (psjip and sip) looks at the first entry and matches the A.A.A.A address to the trunk [CM2895XXXX]. For Voice Call and DID routing, this is not that big of an issue. But when it comes to FAX calls (Re-invite to T.38 connection), or any calls which will require a RE-INVITE, this is a big problem because Asterisk will be using authentication credentials from the MATCHED TRUNK instead of the correct FAX trunk, which will fail.
Temporary work-around for a single FAX trunk and multiple Voice trunks is as follows:
- Setup the Fax trunk in PJSIP and test.
- Setup the voice trunks in PJSIP, BUT set the match (permit) in the trunk settings to a dummy IP address.
This will cause all incoming calls from the same VOIP provider to be matched as the FAX trunk so T.38 re-invite will work.
Alternatively, one can surmise using the “line” parameter under PJSIP to have virtual lines for this purpose. However, not all itsps supports this, and you will need to edit Freepbx custom files to enable at the moment.
Note that for some reason, when I add the following to the pjsip registration custom post file:
The PJSIP does not create the FAX2895XXXX endpoint even though the section exist (and is auto generated by Freepbx) in the PJSIP endpoint conf file. Solution is to manual create another endpoint with a different name but same setting (just copy the generated endpoint and past in custom as a different name), and set the line endpoint to the custom endpoint name.
Theoretically, it should work. But seems that my itsp does not support the “line” option on PJSIP registration so I will have to be content with just using a single FAX line…