Infactum / tg2sip

Telegram <-> SIP voice gateway
GNU General Public License v2.0
281 stars 104 forks source link

Server configuration #6

Closed SimonTheCat closed 5 years ago

SimonTheCat commented 5 years ago

How to configure Astrarisk/Freswitch for tg2sip?

Infactum commented 5 years ago

You should connect TG2SIP as an ordinary SIP trunk without registration.

SimonTheCat commented 5 years ago

` [10:55:58.088][t:1111][p:1111][pjsip][debug] Module "mod-pjsua-log" registered [10:55:58.089][t:1111][p:1111][pjsip][debug] Module "mod-tsx-layer" registered [10:55:58.089][t:1111][p:1111][pjsip][debug] Module "mod-stateful-util" registered [10:55:58.090][t:1111][p:1111][pjsip][debug] Module "mod-ua" registered [10:55:58.091][t:1111][p:1111][pjsip][debug] Module "mod-100rel" registered [10:55:58.091][t:1111][p:1111][pjsip][debug] Module "mod-pjsua" registered [10:55:58.092][t:1111][p:1111][pjsip][debug] Module "mod-invite" registered [10:55:58.093][t:1111][p:1111][pjsip][debug] select() I/O Queue created (0x56387dec22e8) [10:55:58.097][t:1111][p:1111][pjsip][debug] Module "mod-evsub" registered [10:55:58.097][t:1111][p:1111][pjsip][debug] Module "mod-presence" registered [10:55:58.098][t:1111][p:1111][pjsip][debug] Module "mod-mwi" registered [10:55:58.098][t:1111][p:1111][pjsip][debug] Module "mod-refer" registered [10:55:58.099][t:1111][p:1111][pjsip][debug] Module "mod-pjsua-pres" registered [10:55:58.100][t:1111][p:1111][pjsip][debug] Module "mod-pjsua-im" registered [10:55:58.102][t:1111][p:1111][pjsip][debug] Module "mod-pjsua-options" registered [10:55:58.103][t:1111][p:1111][pjsip][debug] 1 SIP worker threads created [10:55:58.103][t:1111][p:1111][pjsip][info] pjsua version 2.8-svn for Linux-4.15.0.42/x86_64/glibc-2.27 initialized [10:55:58.103][t:1111][p:1111][pjsip][debug] PJSUA state changed: CREATED --> INIT [10:55:58.104][t:1111][p:1111][pjsip][debug] Setting null sound device.. [10:55:58.105][t:1111][p:1111][pjsip][debug] Opening null sound device.. [10:55:58.105][t:1111][p:1111][pjsip][debug] SIP UDP socket reachable at 192.168.0.105:5060 [10:55:58.106][t:1111][p:1111][pjsip][debug] SIP UDP transport started, published address is 192.168.0.105:5060 [10:55:58.106][t:1111][p:1111][pjsip][debug] PJSUA state changed: INIT --> STARTING [10:55:58.106][t:1111][p:1111][pjsip][debug] Module "mod-unsolicited-mwi" registered [10:55:58.106][t:1111][p:1111][pjsip][debug] PJSUA state changed: STARTING --> RUNNING [10:55:58.106][t:1111][p:1111][pjsip][debug] Adding account: id=sip:tg@192.168.107 [10:55:58.106][t:1111][p:1111][pjsip][debug] Account sip:tg@192.168.107 added with id 0 [10:55:58.136][t:1111][p:1111][core][info] Loading contacts cache [10:55:58.138][t:1120][p:1111][core][info] TG client authorization ready [10:55:58.142][t:1111][p:1111][core][info] Loaded 0 usernames and 6 phones into contacts cache [10:55:58.380][t:1120][p:1111][core][info] TG client connected [10:55:59.106][t:1114][p:1111][pjsip][debug] Closing sound device after idle for 1 second(s) [10:55:59.107][t:1114][p:1111][pjsip][debug] Closing null sound device.. [10:56:17.022][t:1114][p:1111][pjsip][debug] RX 1078 bytes Request msg INVITE/cseq=8105 (rdata0x56387def2c08) from UDP 192.168.0.107:5060: INVITE sip:+1XXXXXXXXXX@192.168.0.100:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=z9hG4bKPjc2c1c821-149b-4ad8-acb9-8dc0606d4e24 From: "260" sip:260@192.168.0.107;tag=317d3b40-06f0-4ef6-bda7-badf5cc798ab To: sip:+1XXXXXXXXXX@192.168.0.100 Contact: sip:asterisk@192.168.0.107:5060 Call-ID: 8bad1e2d-faf5-40d9-955a-20dccee83a8e CSeq: 8105 INVITE Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER Supported: 100rel, timer, replaces, norefersub Session-Expires: 1800 Min-SE: 90 Max-Forwards: 70 User-Agent: FPBX-14.0.5.2(13.19.1) Content-Type: application/sdp Content-Length: 398

v=0 o=- 2088740370 2088740370 IN IP4 192.168.0.107 s=Asterisk c=IN IP4 192.168.0.107 t=0 0 m=audio 11356 RTP/AVP 0 8 3 111 9 107 101 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:3 GSM/8000 a=rtpmap:111 G726-32/8000 a=rtpmap:9 G722/8000 a=rtpmap:107 opus/48000/2 a=fmtp:107 useinbandfec=1 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 a=ptime:20 a=maxptime:20 a=sendrecv

--end msg-- [10:56:17.026][t:1114][p:1111][pjsip][debug] Incoming Request msg INVITE/cseq=8105 (rdata0x56387def2c08) [10:56:17.026][t:1114][p:1111][pjsip][debug] Call 0: initializing media.. [10:56:17.027][t:1114][p:1111][pjsip][debug] RTP socket reachable at 192.168.0.100:4000 [10:56:17.028][t:1114][p:1111][pjsip][debug] RTCP socket reachable at 192.168.0.100:4001 [10:56:17.028][t:1114][p:1111][pjsip][debug] Media index 0 selected for audio call 0 [10:56:17.029][t:1114][p:1111][core][debug] incoming SIP call #0 from "260" sip:260@192.168.0.107 to sip:+1XXXXXXXXXX@192.168.0.100 with call-id 8bad1e2d-faf5-40d9-955a-20dccee83a8e [10:56:17.029][t:1111][p:1111][core][debug] [1111-1] associated with SIP#0 [10:56:17.029][t:1111][p:1111][core][debug] [1111-1] setting SIP #0 in ringing mode [10:56:17.029][t:1111][p:1111][pjsip][debug] Answering call 0: code=180 [10:56:17.030][t:1114][p:1111][pjsip][debug] Call 0: deinitializing media.. [10:56:17.031][t:1114][p:1111][pjsip][debug] Call 0: cleaning up provisional media, prov_med_cnt=1, med_cnt=0 [10:56:17.031][t:1114][p:1111][pjsip][debug] TX 394 bytes Response msg 406/INVITE/cseq=8105 (tdta0x7f8674008d18) to UDP 192.168.0.107:5060: SIP/2.0 406 Not Acceptable Via: SIP/2.0/UDP 192.168.0.107:5060;rport=5060;received=192.168.0.107;branch=z9hG4bKPjc2c1c821-149b-4ad8-acb9-8dc0606d4e24 Call-ID: 8bad1e2d-faf5-40d9-955a-20dccee83a8e From: "260" sip:260@192.168.0.107;tag=317d3b40-06f0-4ef6-bda7-badf5cc798ab To: sip:+1XXXXXXXXXX@192.168.0.100;tag=mMsyNDCpcmtKMUI0lK9X8rYzFnVeAQ7W CSeq: 8105 INVITE Content-Length: 0

--end msg-- [10:56:17.033][t:1114][p:1111][pjsip][debug] RX 439 bytes Request msg ACK/cseq=8105 (rdata0x7f867400f838) from UDP 192.168.0.107:5060: ACK sip:+1XXXXXXXXXX@192.168.0.100:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=z9hG4bKPjc2c1c821-149b-4ad8-acb9-8dc0606d4e24 From: "260" sip:260@192.168.0.107;tag=317d3b40-06f0-4ef6-bda7-badf5cc798ab To: sip:+1XXXXXXXXXX@192.168.0.100;tag=mMsyNDCpcmtKMUI0lK9X8rYzFnVeAQ7W Call-ID: 8bad1e2d-faf5-40d9-955a-20dccee83a8e CSeq: 8105 ACK Max-Forwards: 70 User-Agent: FPBX-14.0.5.2(13.19.1) Content-Length: 0

--end msg-- [10:56:17.034][t:1111][p:1111][pjsip][info] Invalid call_id 0 in pjsua_call_answer() [10:56:17.035][t:1111][p:1111][pjsip][error] pjsua_call_answer2(id, param.p_opt, prm.statusCode, param.p_reason, param.p_msg_data) error: INVITE session already terminated (PJSIP_ESESSIONTERMINATED) (status=171140) [../src/pjsua2/call.cpp:582] [10:56:17.040][t:1111][p:1111][pjsip][debug] Call 0 hanging up: code=500.. [10:56:17.040][t:1111][p:1111][pjsip][info] Invalid call_id 0 in pjsua_call_hangup() [10:56:17.040][t:1111][p:1111][pjsip][error] pjsua_call_hangup(id, prm.statusCode, param.p_reason, param.p_msg_data) error: INVITE session already terminated (PJSIP_ESESSIONTERMINATED) (status=171140) [../src/pjsua2/call.cpp:591] [10:56:17.040][t:1111][p:1111][core][error] INVITE session already terminated (PJSIP_ESESSIONTERMINATED) [10:56:25.434][t:1114][p:1111][pjsip][debug] RX 414 bytes Request msg OPTIONS/cseq=21271 (rdata0x7f8674008c98) from UDP 192.168.0.107:5060: OPTIONS sip:192.168.0.100:5060 SIP/2.0 Via: SIP/2.0/UDP 192.168.0.107:5060;rport;branch=z9hG4bKPjd9c59247-e158-42f1-8760-68a1a900cb56 From: sip:tg@192.168.0.107;tag=75497dce-76e7-4c95-8c4c-8974b72dba3f To: Contact: sip:tg@192.168.0.107:5060 Call-ID: 2c443263-d711-4b16-abe7-3dbc4b67048c CSeq: 21271 OPTIONS Max-Forwards: 70 User-Agent: FPBX-14.0.5.2(13.19.1) Content-Length: 0

--end msg-- [10:56:25.438][t:1114][p:1111][pjsip][debug] TX 749 bytes Response msg 200/OPTIONS/cseq=21271 (tdta0x7f867400ac68) to UDP 192.168.0.107:5060: SIP/2.0 200 OK Via: SIP/2.0/UDP 192.168.0.107:5060;rport=5060;received=192.168.0.107;branch=z9hG4bKPjd9c59247-e158-42f1-8760-68a1a900cb56 Call-ID: 2c443263-d711-4b16-abe7-3dbc4b67048c From: sip:tg@192.168.0.107;tag=75497dce-76e7-4c95-8c4c-8974b72dba3f To: ;tag=z9hG4bKPjd9c59247-e158-42f1-8760-68a1a900cb56 CSeq: 21271 OPTIONS Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Accept: application/sdp, application/pidf+xml, application/xpidf+xml, application/simple-message-summary, message/sipfrag;version=2.0, application/im-iscomposing+xml, text/plain Supported: replaces, 100rel, timer, norefersub Allow-Events: presence, message-summary, refer Content-Length: 0

--end msg--

`

SIP/2.0 406 Not Acceptable

Infactum commented 5 years ago

TG account you are using as a gateway and the one your are calling are the same? If so, that won't work due to TG limitations. Also check, that opus frequency is set to 48kHz and raw_pcm=false in gateway config. Or you could use raw_pcm=true + L16@48k codec.

SimonTheCat commented 5 years ago

You are right, problem with codecs.

Temur-Maksudov commented 5 years ago

@Infactum Can you check my setting file, why a cant make a call. I use an Cisco Call Manager. Call Manager address is 10.2.2.10 Sip Trunk on Call Manager hunted on 10.2.2.70 TG2SIP gw has address 10.2.2.70.

Settings.ini part of SIP------------------------------------------------------ [sip] public_address=0.0.0.0 ; Address to advertise as the address UDP transport.

;stun_server=

port=5060 ;port_range=0 ; Specify the port range for socket binding, relative to the start ; port number specified in port.

id_uri=sip:10.2.2.10:5060 ; The Address of Record or AOR, that is full SIP URL that identifies the account. ; The value can take name address or URL format, and will look something ; like "sip:account@serviceprovider".

callback_uri=318@10.2.2.10:5060 ; SIP URI for TG->SIP incoming calls processing

raw_pcm=false ; use L16@48k codec if true or OPUS@48k otherwise ; keep true for lower CPU consumption

thread_count=1 ; Specify the number of worker threads to handle incoming RTP ; packets. A value of one is recommended for most applications.


Console output with pjsip debugging-------------------------------------- [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-pjsua-log" registered [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-tsx-layer" registered [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-stateful-util" registered [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-ua" registered [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-100rel" registered [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-pjsua" registered [02:35:58.244][t:1934][p:1934][pjsip][debug] Module "mod-invite" registered [02:35:58.245][t:1934][p:1934][pjsip][debug] select() I/O Queue created (0x561cd7e2aea8) [02:35:58.249][t:1934][p:1934][pjsip][debug] Module "mod-evsub" registered [02:35:58.249][t:1934][p:1934][pjsip][debug] Module "mod-presence" registered [02:35:58.249][t:1934][p:1934][pjsip][debug] Module "mod-mwi" registered [02:35:58.250][t:1934][p:1934][pjsip][debug] Module "mod-refer" registered [02:35:58.250][t:1934][p:1934][pjsip][debug] Module "mod-pjsua-pres" registered [02:35:58.250][t:1934][p:1934][pjsip][debug] Module "mod-pjsua-im" registered [02:35:58.250][t:1934][p:1934][pjsip][debug] Module "mod-pjsua-options" registered [02:35:58.250][t:1934][p:1934][pjsip][debug] 1 SIP worker threads created [02:35:58.250][t:1934][p:1934][pjsip][info] pjsua version 2.8-svn for Linux-4.9.0.8/x86_64/glibc-2.27 initialized [02:35:58.250][t:1934][p:1934][pjsip][debug] PJSUA state changed: CREATED --> INIT [02:35:58.250][t:1934][p:1934][pjsip][debug] Setting null sound device.. [02:35:58.250][t:1934][p:1934][pjsip][debug] Opening null sound device.. [02:35:58.252][t:1934][p:1934][pjsip][debug] SIP UDP socket reachable at 10.2.2.70:5060 [02:35:58.252][t:1934][p:1934][pjsip][debug] SIP UDP transport started, published address is 10.2.2.70:5060 [02:35:58.252][t:1934][p:1934][pjsip][debug] PJSUA state changed: INIT --> STARTING [02:35:58.252][t:1934][p:1934][pjsip][debug] Module "mod-unsolicited-mwi" registered [02:35:58.252][t:1934][p:1934][pjsip][debug] PJSUA state changed: STARTING --> RUNNING [02:35:58.252][t:1934][p:1934][pjsip][debug] Adding account: id=sip:10.2.2.10:5060 [02:35:58.253][t:1934][p:1934][pjsip][debug] Account sip:10.2.2.10:5060 added with id 0 [02:35:58.529][t:1934][p:1934][core][info] Loading contacts cache [02:35:58.529][t:1943][p:1934][core][info] TG client authorization ready [02:35:58.654][t:1934][p:1934][core][info] Loaded 111 usernames and 360 phones into contacts cache [02:35:58.787][t:1943][p:1934][core][info] TG client connected [02:35:59.252][t:1937][p:1934][pjsip][debug] Closing sound device after idle for 1 second(s) [02:35:59.252][t:1937][p:1934][pjsip][debug] Closing null sound device.. [02:36:05.079][t:1934][p:1934][pjsip][debug] Making call with acc #0 to 318@10.2.2.10:5060 [02:36:05.079][t:1934][p:1934][pjsip][error] Unable to make call: Invalid Request URI (PJSIP_EINVALIDREQURI) [status=171042] [02:36:05.079][t:1934][p:1934][pjsip][debug] Call 0: deinitializing media.. [02:36:05.080][t:1934][p:1934][pjsip][error] pjsua_call_make_call(acc.getId(), &pj_dst_uri, param.p_opt, this, param.p_msg_data, &id) error: Invalid Request URI (PJSIP_EINVALIDREQURI) (status=171042) [../src/pjsua2/call.cpp:566] [02:36:09.368][t:1934][p:1934][pjsip][debug] Making call with acc #0 to 318@10.2.2.10:5060 [02:36:09.368][t:1934][p:1934][pjsip][error] Unable to make call: Invalid Request URI (PJSIP_EINVALIDREQURI) [status=171042] [02:36:09.368][t:1934][p:1934][pjsip][debug] Call 1: deinitializing media.. [02:36:09.368][t:1934][p:1934][pjsip][error] pjsua_call_make_call(acc.getId(), &pj_dst_uri, param.p_opt, this, param.p_msg_data, &id) error: Invalid Request URI (PJSIP_EINVALIDREQURI) (status=171042) [../src/pjsua2/call.cpp:566]

danielgt82 commented 5 years ago

callback_uri=318@10.2.2.10:5060;
to callback_uri=sip:318@10.2.2.10:5060;