nicolaipre / DiscordPhone

DiscordPhone - A bot that will let you call phone numbers directly from Discord.
MIT License
33 stars 7 forks source link

Trouble Registering the Softphone #15

Closed kilian579 closed 3 years ago

kilian579 commented 3 years ago

The Discordphone-Client seems to have (random) problems registering as a softphone. I've looked at it in wireshark -> it sends out about 15 "REGISTER" requests, but doesn't get an answer.

Has this problem occurred to you and were you able to fix it?

Furthermore, would you need help with this project? I've seen, that answering a call is not yet implemented.

nicolaipre commented 3 years ago

Hi.

Do you have an Asterisk PBX instance set up that you are registering with? I have only tested this project with Asterisk and SIP, and I am not sure how it would function towards other systems and/or protocols.

Since this project depends on softphone, I would recommend that you use the example.py in that library to test your SIP configuration before using it with DiscordPhone.

That being said, there are some bugs with DiscordPhone too, where the audio stops working from time to time. I have not been able to figure out exactly what is causing this, but it is related to the unstable wrapper around PJSIP/PJSUA.

I have not had time lately to investigate this problem further, so anyone wanting to help implement stuff and improve the project is very welcome! :-)

kilian579 commented 3 years ago

Ok, seems like i should have posted this issue on softphone then. Playing around with the example.py is just what I did - it just rarely manages to register as a softphone.

I'am registering the phone with my WiFi router - the protocol is SIP.

The problem seems to be the REGISTER-requests, that the softphone sends out. They never get responded to by the router. Looking at other softphe applications with Wireshark, they usually get a "Status: 200 OK"-response after their first REGISTER-request. I didn't find the difference between the requests, but that would be my first guess.

Edit: I could send you my public sip login, so that you can check if you've dealt with this issue before.

nicolaipre commented 3 years ago

No problem! Does not really matter where the issue is to me. It affects this project too, so here is fine.

I am not sure if I can be of further help here, as I would have to debug it myself. What I would recommend though, is testing against an Asterisk PBX instance running with a config (sip.conf) similar to this:

[general]
allowguest=no
context=default
bindport=7878
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
allow=gsm
allow=g723
allow=g726
allow=speex
alwaysauthreject=yes
externip=REPLACE-WITH-YOUR-PUBLIC-IP-ADDRESS (Make sure bindport is port-forwarded if you are behind NAT)

[201]
type=friend
host=dynamic
context=from-internal
username=201
secret=REPLACE-WITH-A-SECRET-PASSWORD
qualify=yes
nat=force_rport,comedia

[trunk]
type=peer
host=REPLACE-WITH-YOUR-SIP-TRUNK-PROVIDER-ENDPOINT
canreinvite=yes
port=5060
insecure=port,invite
disallow=all
allow=ulaw
context=from-trunk

This way the Asterisk PBX will sit between softphone and your SIP Provider (in this case your router), and you should be able to connect softphone to the Asterisk PBX instance with the following .env file for softphone (for outbound calls):

# Example environment configuration

# For incoming calls
SIP_INBOUND_REALM =
SIP_INBOUND_HOST  =
SIP_INBOUND_PORT  =
SIP_INBOUND_USER  =
SIP_INBOUND_PASS  =
SIP_INBOUND_URI   =
SIP_INBOUND_PROXY =

# For outgoing calls
SIP_OUTBOUND_REALM = 'asterisk'
SIP_OUTBOUND_HOST  = 'REPLACE-WITH-YOUR-PUBLIC-IP-ADDRESS (same as externip= in sip.conf)
SIP_OUTBOUND_PORT  = '7878'
SIP_OUTBOUND_USER  = '201'
SIP_OUTBOUND_PASS  = 'REPLACE-WITH-A-SECRET-PASSWORD (same as secret= in block [201] in sip.conf)'
SIP_OUTBOUND_URI   =
SIP_OUTBOUND_PROXY =

I tested example.py with this configuration right now, and registered successfully. You could also check the example.log file after you have attempted to run example.py. Upon successful registration it should contain a line similar to:

2021-01-25 07:58:23,374 softphone.Softphone INFO Successfully registered sip:201@192.168.10.202:49571, status: 200 (OK).

Could you check this file and see if there is any relevant information or error messages regarding registration?

nicolaipre commented 3 years ago

Closing to due inactivity.