Sending fax between two asterisk servers

i have two asterisk servers version 16 and i want to send fax from server 1 to server 2. I created a sip trunk in asterisk server 1 :

[sip_provider_39]
type = endpoint
transport=0.0.0.0-udp
context=fax-tx
disallow=all
allow=ulaw
outbound_auth=sip_provider_39
aors=sip_provider_39
direct_media = no
t38_udptl = yes
t38_udptl_ec = none
t38_udptl_maxdatagram = 400
t38_udptl_nat = no
t38_udptl_ipv6 = no

[sip_provider_39]
type = aor
contact=sip:4010@192.168.1.26:5060

[sip_provider_39]
type = identify
endpoint = sip_provider_39
match= 192.168.1.26

[sip_provider_39]
type = auth
auth_type = userpass
username=4010
password=mypassword

[sip_provider_39]
type=registration
transport=0.0.0.0-udp
outbound_auth=sip_provider_39
retry_interval = 30
max_retries = 10
expiration = 30
contact_user = 4010
server_uri=sip:192.168.1.26
client_uri=sip:4010@192.168.1.26
retry_interval = 60

and in server 2 this is the extension 4010 :
[4010]
type=endpoint
transport=0.0.0.0-udp
context= incoming-fax
disallow=all
allow=alaw,ulaw
trust_id_outbound=yes
callerid=Spaceman Spiff <4010>
auth=auth_4010
aors=4010

[4010]
type=aor
max_contacts=2
remove_existing=yes
qualify_frequency=60
authenticate_qualify=no
[identify_4010]
type=identify
endpoint=4010
[auth_4010]
type=auth
auth_type=userpass
password=mypassword
username=4010

but when i send the fax i get this issue in asterisk 1cli:
[Apr 2 08:04:46] WARNING[23220]: res_pjsip_outbound_authenticator_digest.c:551 digest_create_request_with_auth: Endpoint: ‘sip_provider_39’: Authentication credentials not accepted by server.

and server 2 cli:
NOTICE[27027]: res_pjsip/pjsip_distributor.c:673 log_failed_request: Request ‘INVITE’ from ‘“Anonymous” sip:anonymous@anonymous.invalid’ failed for ‘192.168.1.8:5060’ (callid: 99834a4d-b245-47d3-adc6-20f5cb311d4d) - Failed to authenticate

This is not a fax problem.

This is endpoint 4010, not extension 4010. Extension 4010 would be in extensions.conf.

This is incomplete, and you would not normally have one at all w hen using registration.

In the absence of rules requiring a match on authentication user name (which are better avoided). or IP address, which I assume you would have used if you could (although maybe you didn’t realise you could), rather than registration, the match will be attempted on the From: user name, but that is anoymous and the only thing available to mach is 4010.

please what should i do exactly to allow sending fax using sip trunk, and yes you are right 4010 is an endpoint but how can i specify the rule in server2 to receive fax

Your problem is not fax, but that you haven’t configured the “trunk” properly. If both sides know the other’s address, which would normally be the case, you use the AOR and identify formats from the UAC side, on both sides, with the names changed, appropriately, and throw away the registration section. Actually if you only make calls one way, you don’t need the AOR on the UAS side, and you don’t need the identify on the UAS side.

You will need an actual extension 4010, and I would suggest renaming the endpoint 4010, and changing the UAC’s contact information, to avoid confusion with the extension.