Alter.Org.UA
 << Back Home EN en   Donate Donate

Linphonec setup

The original task was running linphonec (console version of Linphone) automatically on system startup and manage it from other application later. There were several problems. Not unique, google finds same questions. But none is answered :)
PS. originally, it was about Linux, but there are some similar problems with Windows too.

  • SIP autoregister works sometimes
  • sound card works under GUI but doesn't work in console version.
  • sound card is not always detected properly when running console or daemon version.
  • systemd doesn't start linphonec in any documented way
  • strange connection problems without any visible reason

SIP autoregister

SIP autoregister depends on proper config (with password specified) and proper path to config. Config search alorithm is environment-dependent. Use -c /path/to/.linphonerc explicitly and force run under proper user (use sudo -u).

Under Windpows config file is placed at \Users\UserName\AppData\Local\linphone\linphonerc. Note, it has no dot character in filename.

  • You can generate config from GUI, find it and specify path explicitly with -c (GUI and CLI configs may differ!).
  • You can run linphonec and use proxy add command.
  • You can update .linphonerc manually.
    Note: username is auth. user for remote server. reg_identity *** and userid are your number (extension in asterisk terms), it often may, but not must be equal to username, ask provider/sysadmin if not sure. reg_identity - how local phone identifies itself for incoming calls, userid - how to represent itself for outgoing calls (may differ if server allows).

.linphonerc

[proxy_0]
reg_proxy=sip:example.com
reg_route=<sip:your.outbound.proxy.if.used>
reg_identity=sip:***@example.com
reg_expires=3600
reg_sendregister=1
publish=1
dial_escape_plus=0

[auth_info_0]
username=your_user
userid=your_user
passwd=your_password
realm="example.com"

Sound card issues

Sound problem appeared to be build-dependent and environment-dependent. Some builds of linphonec didn't work with soundcard, however GUI linphone worked fine. Setting any visible card from concole (sound list, sound use) doesn't help. Just try another build in this case.

Config search algorithm is environment-dependent, access to sound card may be too. So it is better to use -c /path/to/.linphonerc explicitly and force run under proper user (use sudo -u).

Linux Systemd support

Systemd assumes that executable is started and not exited/forked. Thus, linphonecsh init will now work. Because linphonecsh runs linphonec as separate process and exits. Then systemd kills entire process tree.
Run linphonecsh init (may be with some other switches, e.g. for autoanswer or register) and see in process list (ps axwwu) what exact command line and user are used. You will see undocumented option --pipe which instructs linphonec to listen to commands on pipe instead of standard console. linphonecsh uses this pipe for sending commands to lin phonec running as daemon. Also, some other undocumented option -C is used. This would be proper command line for running from systemd.

/etc/systemd/system/linphone.service

[Unit]
Description = Start linphone daemon

[Service]
User=your_local_user
WorkingDirectory=/home/your_local_user
ExecStart=/usr/bin/linphonec --pipe -C -c /home/your_local_user/.linphonerc
ExecStop=/usr/bin/linphonecsh exit
TimeoutStopSec=10                                                                      

[Install]
WantedBy=multi-user.target

Windows background operation (daemon-like) support

Often problem - linphonec works fine, but linphonecsh can't start linphone in proper environment (like under Linux ;), it can't register, init sound or dial for some reason. Proper solution is running linphoned - special windows-specific executable for running as daemon in background with explicit config file specification. Actually, linphonecsh just runs it on init. Note: -C is essential too.

linphoned.exe --pipe -C -c C:\Users\UserName\AppData\Local\linphone\linphonerc

You can check if it is running via task manager or from console with wkill.exe

wkill.exe -l -N "linphoned"

Note: running instance of linphoned may be invisible for Task Manager and linphonecsh status register. And it may prevent other linphone instances from SIP registration with 401 Unauthorized error.

Note 2: use linphonecsh dial YOURNUM@your_server for dialing. Other syntax invariants may cause linphoned crash during SIP session setup.

Linphone doesn't work without internet connection

ortp-error-Error in connect: No such file or directory

Appears when running without internet conenction, in LAN only mode. The key problem is default gatway detection. It must be defined !!!. Internally linphone use some tricky algorithm for determining interface and source IP for connection with SIP server. And if it fails, linphone uses route to predefined static IP in the internet. So, you must either configure default gateway on network card or directly specify some low-priority default route like this (make it persistent with -p if you want)

route [-p] add 0.0.0.0 mask 0.0.0.0 MY.DEF.GW.IP metric 1000

2020.08.06


См. также:


FB or mail alterX@alter.org.ua (remove X)   Share
Автор: Alter (Александр А. Телятников) Сервер: Apache+PHP под FBSD © 2002-2020