Connecting Asterisk to Asterisknow using SIP Trunk is not Working

I’m trying to connect Asterisk server to AsteriskNOW server using SIP trunk

Here is the configuration for the Asterisk server [6XXX extensions]** server1**

extension.com
-------------------
[from-internal]
exten => _5XXX,1,NoOP(Call Phone)
exten => _5XXX,n,Dial(SIP/${EXTEN})
exten => _5XXX,n,Hangup()
exten => _6XXX,1,NoOp()
exten => _6XXX,n,Dial(SIP/5001)
exten => _6XXX,n,Hangup()

sip.conf
------------
[5001]
type=friend
context=from-internal
host=dynamic
secret=123456
disallow=all
allow=ulaw

[5002]
type=friend
context=from-internal
host=dynamic
secret=123456
disallow=all
allow=ulaw


[general]
register => server1:pass@server2-ip/server2

[server2]
type=friend
host=server2-ip
secret=123456
context=from-internal
insecure=invite
disallow=all
allow=ulaw

Here is the configuration for the AsteriskNow server [7XXX extensions]** server2**

Trunk
--------
Trunk Name: trunk_to_server1
Trunk Name: trunk_to_server1
PEER Details: 
		host=server1-ip
		username=server1
		secret=pass
		type=peer
		fromuser=server1

USER Context:server2
USER Details:
		secret=pass
		type=user
		context=from-trunk

Outbound Routes 
-------------------------

Route Name: server2
Dial Patterns:
		()+  +| 5XXX /    ]
Trunk Sequance:
		0:  trunk_to_server1
---------------------------------------------------------------------------------------------------------------

the issue:
when calling from Asterisknow to Asterisk I redirected to public context and get the demo audio

here is the outbut from the Asterisk server

== Using SIP RTP CoS mark 5
    -- Executing [s@public:1] wait("SIP/server2-ip-00000017", "1")
    -- Executing [s@public:1] answer("SIP/server2-ip-00000017", "")
       > 0x1c5e870 -- Probation passed - setting RTP source address to server2-ip:11714
    -- Digit timeout set to 5.000
    -- Response timeout set to 10.000
    -- Executing [s@public:1] background("SIP/server2-ip-00000017", "demo-congrats")
    -- <SIP/server2-ip-00000017> Playing 'demo-congrats.ulaw' (language 'en')
  == Spawn extension (public, s, 1) exited non-zero on 'SIP/server2-ip-00000017'

I should be redirected to the extension in the Asterisk server, but that is not happening.

Can any one help me to establish a correct SIP trunk between Asterisk and AsteriskNOW.

Your information is incomplete. You have nothing that would result in a public context being used, as the default is default (although I suppose it could have changed).

Your logs are incomplete. I expect to see something saying “not found in”.

You have no logs from the FreePBX side. (NB this is the wrong forum for FreePBX.)

You have the wrong password on the plain Asterisk side. It should be pass.

register is inappropriate when the peer isn’t using host=dynamic.

Almost certainly you want type=peer on everything.

If the environment is trusted, ditch all the secrets and the insecure. If it is not, set the same secret on both (or reciprocal secret and remotesecret’s) and ditch the insecure.

Setting fromuser defeats caller ID and won’t even result in a sensible user match, as it is trying to match server2.

First thanks for your reply, Sorry for the wrong information and here is the complete issue.
I’m trying to connect Asterisk server to AsterisNow server using SIP Trunk.

Here is the configuration for the AsteriskNOW server [7XXX extensions]** server1**


Trunk:

Trunk Name: trunk_to_server2
PEER Details:
host=server2-ip
username=server2
secret=password
type=peer
fromuser=server2

USER Context:server1
USER Details:
secret=password
type=user
context=from-trunk

Outbound Route:

Route Name: server1
Dial Patterns: 6XXX
Trunk Sequance: trunk_to_server1

Here is the configuration for the Asterisk server [6XXX extensions]** server2**

extension.com

[from-internal]
exten => _6XXX,1,NoOP()
exten => _6XXX,n,Dial(SIP/${EXTEN})
exten => _6XXX,n,Hangup()
exten => _7XXX,1,NoOp()
exten => _7XXX,n,Dial(SIP/${EXTEN}@server1)
exten => _7XXX,n,Hangup()

sip.conf

[6001]
type=friend
context=from-internal
host=dynamic
secret=password
disallow=all
allow=ulaw

[6002]
type=friend
context=from-internal
host=dynamic
secret=password
disallow=all
allow=ulaw

[general]
register => server2:password@server1-ip/server1

[server1]
type=friend
host=server1-ip
secret=password
context=from-internal
insecure=invite
disallow=all
allow=ulaw

the issue:
when calling from Asterisknow ** server1** to Asterisk ** server2**
I redirected to public context

here is the log of the Asterisk server

== Using SIP RTP CoS mark 5
[Sep 7 17:35:43] NOTICE[1897][C-00000003]: chan_sip.c:25872 handle_request_invite: Call from ‘’ (server1-ip:5061) to extension ‘6001@trunk_to_test2’ rejected because extension not found in context ‘public’.

here is the log of the AsteriskNOW server

== Using SIP RTP CoS mark 5
– Called SIP/trunk_to_test2/6001@trunk_to_test2
== Everyone is busy/congested at this time (1:0/0/1)
– Executing [s@macro-dialout-trunk:23] NoOp(“PJSIP/7403-0000006f”, “Dial failed for some reason with DIALSTATUS = CHANUNAVAIL and HANGUPCAUSE = 1”) in new stack

I hope you can help me in this issue