sdesalve / hassio-addons

MIT License
86 stars 21 forks source link

Was working but now don't work #48

Closed rlcobos2 closed 2 years ago

rlcobos2 commented 2 years ago

Sorry, i have read the information ( but can't found the problem )

My system was working, but from one month or more ago does not work more.

my config: sip_parameters: caller_id_uri: sip:username@sip.voipgain.com realm: '*' username: myusername password: mypass pjsua_custom_options: '--no-tcp'

my script: llamadaalarma: alias: Llamada Avisar Alarma sequence:

my log : [Info] Call ended... [Info] Listening for messages via stdin service call... [Info] Received messages {"call_sip_uri": "sip:+34xxxxxxxx@sip.voipgain.com", "message_tts": " Se ha activado la alarma de casa por un salto perimetral.."} Converting audio file 'https://rlcobos.duckdns.org/api/tts_proxy/bfc0ea497f14201bb2f29ea57de5df3551d02bcc_es_-_google_translate.mp3'... Audio succesfully converted... Starting SIP Client and calling 'sip:+34xxxxxxx@sip.voipgain.com'... This call will be terminated after '50' seconds. 21:27:08.845 os_core_unix.c !pjlib 2.11.1 for POSIX initialized 21:27:08.846 sip_endpoint.c .Creating endpoint instance... 21:27:08.846 pjlib .select() I/O Queue created (0x7f09be132100) 21:27:08.846 sip_endpoint.c .Module "mod-msg-print" registered 21:27:08.847 sip_transport.c .Transport manager created. 21:27:08.847 pjsua_core.c .PJSUA state changed: NULL --> CREATED 21:27:08.865 pjsua_core.c .pjsua version 2.11.1 for Linux-5.10.88/x86_64 initialized 21:27:08.872 pjsua_app.c .Turning sound device -99 -99 ON 21:27:08.872 main.c Ready: Success 21:27:08.875 pjsua_app.c .......Call 0 state changed to CALLING

Account list: [ 0] : does not register Online status: Online *[ 1] sip:usernamevoip@sip.voipgain.com: does not register Online status: Online Buddy list: [ 1] <?> sip:+34xxxxxxx@sip.voipgain.com +=============================================================================+ Call Commands: Buddy, IM & Presence: Account:
m Make new call +b Add new buddy . +a Add new accnt
M Make multiple calls -b Delete buddy -a Delete accnt.
a Answer call i Send IM !a Modify accnt.
h Hangup call (ha=all) s Subscribe presence rr (Re-)register
H Hold call u Unsubscribe presence ru Unregister
v re-inVite (release hold) t ToGgle Online status > Cycle next ac.
U send UPDATE T Set online status < Cycle prev ac.
],[ Select next/prev call +--------------------------+-------------------+
x Xfer call Media Commands: Status & Config:
X Xfer with Replaces
# Send RFC 2833 DTMF cl List ports d Dump status
* Send DTMF with INFO cc Connect port dd Dump detailed
dq Dump curr. call quality cd Disconnect port dc Dump config
V Adjust audio Volume f Save config
S Send arbitrary REQUEST Cp Codec priorities

+-----------------------------------------------------------------------------+ | q QUIT L ReLoad sleep MS echo [0|1|txt] n: detect NAT type | +=============================================================================+ You have 1 active call Current call id=0 to sip:+34xxxxxxxx@sip.voipgain.com [CALLING] 21:27:08.920 tsx0x7f09bdfa16d8 .......Temporary failure in sending Request msg INVITE/cseq=11763 (tdta0x7f09bdf9aaa8), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT) 21:27:09.874 pjsua_app.c .Turning sound device -99 -99 OFF 21:27:40.921 pjsua_app.c ....Call 0 is DISCONNECTED [reason=408 (Request Timeout)] No current call 21:28:00.432 timer.c .Dumping timer heap: 21:28:00.432 timer.c . Cur size: 0 entries, max: 3070 [Info] Call ended... [Info] Listening for messages via stdin service call...

can you help me, please??

sdesalve commented 2 years ago

Could you post full addon logs after starting?

wizdude commented 2 years ago

i'm actually seeing the same thing. i have an inhouse PBX and the PBX is seeing no attempted call, registration or otherwise.

i have configured a device called HASS and told it to dial my extension. this is the same method I use on all my doorphones, cameras, etc.

192.168.80.231 is the IP address of my HA box. 192.168.80.254 is the PBX. 250 is my extension.

here's my logs:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: DSS VoIP Notifier
 VoIP Notifier for Home Assistant
-----------------------------------------------------------
 Add-on version: 3.5.9
 You are running the latest version of this add-on.
 System: Home Assistant OS 7.5  (amd64 / qemux86-64)
 Home Assistant Core: 2022.3.7
 Home Assistant Supervisor: 2022.03.5
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[Info] Starting addon...
PJSUA_CUSTOM_OPTIONS = '--no-tcp'
[Info] Listening for messages via stdin service call...
[Info] Received messages {"call_sip_uri": "sip:250@192.168.80.254", "message_tts": "this is a test message"}
Converting audio file 'http://192.168.80.231:8123/api/tts_proxy/be878249f2f30ad888b9bb632a5de67b967e4bc2_en_-_google_translate.mp3'...
Audio succesfully converted...
Starting SIP Client and calling 'sip:250@192.168.80.254'...
This call will be terminated after '50' seconds.
16:02:34.762         os_core_unix.c !pjlib 2.11.1 for POSIX initialized
16:02:34.763         sip_endpoint.c  .Creating endpoint instance...
16:02:34.763                  pjlib  .select() I/O Queue created (0x7fbd61981100)
16:02:34.763         sip_endpoint.c  .Module "mod-msg-print" registered
16:02:34.763        sip_transport.c  .Transport manager created.
16:02:34.763           pjsua_core.c  .PJSUA state changed: NULL --> CREATED
16:02:34.771           pjsua_core.c  .pjsua version 2.11.1 for Linux-5.10.103/x86_64 initialized
16:02:34.774            pjsua_app.c  .Turning sound device -99 -99 ON
16:02:34.774                 main.c  Ready: Success
16:02:34.775            pjsua_app.c  .......Call 0 state changed to CALLING
>>>>
Account list:
  [ 0] <sip:172.30.33.5:5060>: does not register
       Online status: Online
 *[ 1] sip:HASS@192.168.80.254:5060: does not register
       Online status: Online
Buddy list:
 [ 1] <?>  sip:250@192.168.80.254
+=============================================================================+
|       Call Commands:         |   Buddy, IM & Presence:  |     Account:      |
|                              |                          |                   |
|  m  Make new call            | +b  Add new buddy       .| +a  Add new accnt |
|  M  Make multiple calls      | -b  Delete buddy         | -a  Delete accnt. |
|  a  Answer call              |  i  Send IM              | !a  Modify accnt. |
|  h  Hangup call  (ha=all)    |  s  Subscribe presence   | rr  (Re-)register |
|  H  Hold call                |  u  Unsubscribe presence | ru  Unregister    |
|  v  re-inVite (release hold) |  t  ToGgle Online status |  >  Cycle next ac.|
|  U  send UPDATE              |  T  Set online status    |  <  Cycle prev ac.|
| ],[ Select next/prev call    +--------------------------+-------------------+
|  x  Xfer call                |      Media Commands:     |  Status & Config: |
|  X  Xfer with Replaces       |                          |                   |
|  #  Send RFC 2833 DTMF       | cl  List ports           |  d  Dump status   |
|  *  Send DTMF with INFO      | cc  Connect port         | dd  Dump detailed |
| dq  Dump curr. call quality  | cd  Disconnect port      | dc  Dump config   |
|                              |  V  Adjust audio Volume  |  f  Save config   |
|  S  Send arbitrary REQUEST   | Cp  Codec priorities     |                   |
+-----------------------------------------------------------------------------+
|  q  QUIT   L  ReLoad   sleep MS   echo [0|1|txt]     n: detect NAT type     |
+=============================================================================+
You have 1 active call
Current call id=0 to sip:250@192.168.80.254 [CALLING]
>>> 16:02:34.782      tsx0x7fbd617f06e8  .......Temporary failure in sending Request msg INVITE/cseq=14888 (tdta0x7fbd617e9aa8), will try next server: Unsupported transport (PJSIP_EUNSUPTRANSPORT)
16:02:35.773            pjsua_app.c  .Turning sound device -99 -99 OFF
16:03:24.755            pjsua_app.c  .Call 0 is DISCONNECTED [reason=487 (Request Terminated)]
>>> 16:03:25.262      sip_transaction.c  .....Unable to register CANCEL transaction (key exists)
16:03:25.262           pjsua_call.c  ...Failed to send end session message: Object already exists (PJ_EEXISTS) [status=70015]
16:03:26.280                timer.c  .Dumping timer heap:
16:03:26.280                timer.c  .  Cur size: 1 entries, max: 3070
16:03:26.280                timer.c  .  Entries: 
16:03:26.280                timer.c  .    _id   Id  Elapsed Source
16:03:26.280                timer.c  .    ----------------------------------
16:03:26.280                timer.c  .    3 1   3.982   ../src/pjsua-lib/pjsua_call.c:2848
[Info] Call ended...
[Info] Listening for messages via stdin service call...

happy to provide any more information as required.

sdesalve commented 2 years ago

Use base_url in Google TTS. See docs

Try to use dss_voip34 version.

Let me know

sdesalve commented 2 years ago

Is there any Firewall? Any VoIP call filter? Host machine? amd64 / qemux86-64 what is?

wizdude commented 2 years ago

i did some more debugging and managed to work it out. i'm using Home Assistant OS 64 bit running as a VM on VMware ESXi.

my original config looked like this:

sip_parameters:
  caller_id_uri: sip:HASS@192.168.80.231
  realm: '*'
  username: HASS
  password: secretpassword
pjsua_custom_options: '--no-tcp' 

but the PBX was rejecting a call from a unknown source: Contact 'SIP:HASS@172.30.33.5:5060'

i changed my config to this which now works:

sip_parameters:
  caller_id_uri: sip:HASS@192.168.80.231
  realm: '*'
  username: HASS
  password: secretpassword
pjsua_custom_options: '--no-tcp --contact=sip:HASS@192.168.80.231'

but then i did more testing. if i change "caller_id_uri" to complete rubbish, it still works. i just did: caller_id_uri: sip:blah@1.2.3.4 and the call still goes through (obviously being overridden by the --contact option).

can i ask - is the "caller_id_uri" meant to be the same as the pjsua --contact option?

it looks like it's choosing one of the internal IP's of Homeassistant OS.

perhaps the caller_id_uri should set the --contact option? just a thought.

wizdude commented 2 years ago

one other note. when the call is made and the caller hangs up, you appear to understand this, but still wait for the whole 50 seconds.

17:04:53.781            pjsua_app.c  .....Call 0 state changed to CONNECTING
17:04:53.783            pjsua_app.c  .....Call 0 state changed to CONFIRMED
17:05:00.860     pjsua_app_common.c  ........
  [DISCONNCTD] To: sip:250@192.168.80.254;tag=294-zultys--10359999634894_889941543-4894

    Call time: 00h:00m:07s, 1st res in 133 ms, conn in 1630ms
    #0 audio PCMU @8kHz, sendrecv, peer=192.168.80.254:24650
       SRTP status: Not active Crypto-suite: 
       RX pt=0, last update:00h:00m:00.000s ago
          total 348pkt 55.6KB (69.6KB +IP hdr) @avg=62.9Kbps/78.6Kbps
          pkt loss=0 (0.0%), discrd=0 (0.0%), dup=0 (0.0%), reord=0 (0.0%)
                (msec)    min     avg     max     last    dev
          loss period:   0.000   0.000   0.000   0.000   0.000
          jitter     :   0.000   0.381   0.500   0.500   0.068
       TX pt=0, ptime=20, last update:never
          total 265pkt 42.4KB (53.0KB +IP hdr) @avg=47.9Kbps/59.8Kbps
          pkt loss=0 (0.0%), dup=0 (0.0%), reorder=0 (0.0%)
                (msec)    min     avg     max     last    dev 
          loss period:   0.000   0.000   0.000   0.000   0.000
          jitter     :   0.000   0.000   0.000   0.000   0.000
       RTT msec      :   0.000   0.000   0.000   0.000   0.000
17:05:00.860            pjsua_app.c  ......Call 0 is DISCONNECTED [reason=200 (Normal call clearing)]
17:05:01.860            pjsua_app.c  .Turning sound device -99 -99 OFF
No current call
>>> 17:05:42.644            pjsua_acc.c  .....sip:HASS2@192.168.80.231: unregistration success
17:05:43.844                timer.c  .Dumping timer heap:
17:05:43.844                timer.c  .  Cur size: 0 entries, max: 3070
[Info] Call ended...
[Info] Listening for messages via stdin service call...

at 17:05:00 you recognise that the call was disconnected, but i have to wait until 17:05:42 until you actually end the call. is there any way to finish your processing as soon as the call is disconnected rather than waiting?

i tried setting the "call_duration" to "-1" but then the call hangs up as soon as it dials.

thanks for the great work on this add-on, by the way. it's awesome to have SIP integration within Home Assistant :-)

sdesalve commented 2 years ago

Try --ip=ip_of_host

wizdude commented 2 years ago

Try --ip=ip_of_host

that was my first configuration, and it doesn't work. it still attempts to register on my PBX using the 172.30.33.5 address, the only way i was able to get this part working was to use the --contact option.

the logs on the PBX showed that the registration was coming from the IP of the host, but that it was registering as SIP:HASS@172.30.33.5:5060

i believe that the caller_id_uri should be setting --contact as well, but i don't want you to break anything for happy users.

wizdude commented 2 years ago

oh and for the benefit of the OP, i think VoipGain may require SIP registration. i actually require that on my PBX as well, but left it out of the notes above because it wasn't the cause of my problem.

if you read here: https://www.voipgain.com/sip specifically this line: Registrar : sip.voipgain.com

this means you'll probably have to set some custom options, like: pjsua_custom_options: '--no-tcp --registrar=sip:sip.voipgain.com --reg-timeout=600'

and if you are experiencing problems like i was, you might need to also include --contact=sip:usernamevoip@sip.voipgain.com

hope that helps. sorry to partially hijack this thread, but it looked like your problem may have been very similar to mine.

rlcobos2 commented 2 years ago

GREAT!!!!

This line:

pjsua_custom_options: '--no-tcp --registrar=sip:sip.voipgain.com --reg-timeout=600'

was solved my problem......

Thanks wizdude, thanks to the creator, thanks to the community.

Unique thing, i can't understand why months ago was working without this parameters....