OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
85 stars 48 forks source link

Unable to create database tables with `opensips-cli` #49

Closed zhongdongy closed 4 years ago

zhongdongy commented 4 years ago

Description

Tried to execute opensips-cli on my server (mysql 5.7 on debian 9), but the the python output shows there is no such table: "opensips.version".

I've installed all required dependencies and packages before running opensips-cli. And just confirmed the user for opensips has sufficient privilege to access MySQL database.

After seeing this issue, I checked MySQL. Under opensips database, there is no table. And I suspect the program didn't correctly create the tables.

Thanks for your help!

Details

Command line output

WARNING: database 'opensips' already exists!
INFO: database 'opensips' dropped!
INFO: access works, opensips user already exists
INFO: Running acc-create.sql...
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'opensips.version' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 739, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1494, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 235, in cmdloop
    ret = self.run_command(self.command[0], command, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 341, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/module.py", line 36, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 303, in do_create
    if self.create_tables(db_name, db_url, admin_db) < 0:
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 405, in create_tables
    db.create_module(table_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 247, in create_module
    self.exec_sql_file(import_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 464, in exec_sql_file
    self.__conn.execute(sql)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
    return self._execute_text(object_, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
    parameters,
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1146, "Table 'opensips.version' doesn't exist")
[SQL: INSERT INTO version (table_name, table_version) values ('acc','7')]
(Background on this error at: http://sqlalche.me/e/f405)
   Failed last operation
root@ecs-test:~/opensips# opensips-cli -x database drop
INFO: database 'opensips' dropped!
root@ecs-test:~/opensips# opensips-cli -x database create
INFO: access works, opensips user already exists
INFO: Running drouting-create.sql...
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
_mysql_exceptions.ProgrammingError: (1146, "Table 'opensips.version' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 739, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1494, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/main.py", line 78, in main
    sys.exit(shell.cmdloop())
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 235, in cmdloop
    ret = self.run_command(self.command[0], command, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/cli.py", line 341, in run_command
    return mod[0].__invoke__(cmd, params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/module.py", line 36, in __invoke__
    return f(params)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 303, in do_create
    if self.create_tables(db_name, db_url, admin_db) < 0:
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/modules/database.py", line 405, in create_tables
    db.create_module(table_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 247, in create_module
    self.exec_sql_file(import_file)
  File "/usr/local/lib/python3.5/dist-packages/opensipscli-0.1.0-py3.5.egg/opensipscli/db.py", line 464, in exec_sql_file
    self.__conn.execute(sql)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 982, in execute
    return self._execute_text(object_, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1155, in _execute_text
    parameters,
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1248, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 383, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 128, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1244, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.3.3-py3.5-linux-x86_64.egg/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 255, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 50, in defaulterrorhandler
    raise errorvalue
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 252, in execute
    res = self._query(query)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/cursors.py", line 378, in _query
    db.query(q)
  File "/usr/local/lib/python3.5/dist-packages/mysqlclient-1.3.14-py3.5-linux-x86_64.egg/MySQLdb/connections.py", line 280, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1146, "Table 'opensips.version' doesn't exist")
[SQL: INSERT INTO version (table_name, table_version) values ('dr_gateways','6')]
(Background on this error at: http://sqlalche.me/e/f405)

Environment information

Content Version
Python3 python 3.7
MySQL mysql 5.7
Linux Distribution Debian 9.0

Installed software

opensips, opensips-mysql-module, opensips-cli (via source), mediaproxy-dispatcher, mediaproxy-relay, mediaproxy-web-sessions

OpenSIPS-CLI configuration

The #MYSQL_ROOT# is replaced with actual root password on my server.

[default]
database_name=opensips
database_url=mysql://opensipsuser:opensips_access@localhost
template_uri=mysql://opensipsuser:opensips_access@localhost
database_admin_url=mysql://root:#MYSQL_ROOT#@localhost
database_modules=ALL
database_force_drop=true

Thanks for reading!

liviuchircu commented 4 years ago

hi, @zhongdongy ! How recent is your opensips-cli? There were several fixes in this area, so I suggest you grab the latest version and retry.

PS: template_url has been completely removed

liviuchircu commented 4 years ago

OK, I think I understand what's happening. Are you somehow running Python 3.5.x or below?

Later Edit: it seems not, as you say you're on 3.7... so I don't understand why the standard-create.sql file doesn't get run first.

Can you paste the output of dpkg -L opensips-mysql-module, please? Thank you!

zhongdongy commented 4 years ago

hi, @zhongdongy ! How recent is your opensips-cli? There were several fixes in this area, so I suggest you grab the latest version and retry.

PS: template_url has been completely removed

Hi, @liviuchircu ! Thanks for this information. I've retried this on another virtual machine and it works. fine now. But here is something I noticed during the execution:

The opensips-cli CLI tool just hangs during execution if opensips service is running in background. I tried to re-install opensips-cli but this didn't solve the issue. Then I stopped opensips service and run CLI tool again, it worked!

So I think it works now. And on this VM, I have python3.6 installed for your information.

zhongdongy commented 4 years ago

OK, I think I understand what's happening. Are you somehow running Python 3.5.x or below?

Later Edit: it seems not, as you say you're on 3.7... so I don't understand why the standard-create.sql file doesn't get run first.

Can you paste the output of dpkg -L opensips-mysql-module, please? Thank you!

Thank you @liviuchircu very much for this update. But unfortunately I terminated that specific cloud instance a few days ago so I am unable to provide those information from exact same machine. But with the latest success, I found it works fine with Python 3.6. And here are some related information if it helps:

opensips-cli version

# opensips-cli --version
OpenSIPS CLI 0.1.0

opensips installation

Built from source:

# opensips -V
version: opensips 3.0.2 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, HP_MALLOC, DBG_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll, sigio_rt, select.
git revision: 7e8167853
main.c compiled on 19:02:48 Apr  2 2020 with gcc 7

dpkg output of opensips-mysql-module

# dpkg -L opensips-mysql-module
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/opensips
/usr/lib/x86_64-linux-gnu/opensips/modules
/usr/lib/x86_64-linux-gnu/opensips/modules/db_mysql.so
/usr/lib/x86_64-linux-gnu/opensips/opensipsctl
/usr/lib/x86_64-linux-gnu/opensips/opensipsctl/opensipsctl.mysql
/usr/lib/x86_64-linux-gnu/opensips/opensipsctl/opensipsdbctl.mysql
/usr/share
/usr/share/doc
/usr/share/doc/opensips-mysql-module
/usr/share/doc/opensips-mysql-module/README.db_mysql
/usr/share/doc/opensips-mysql-module/copyright
/usr/share/opensips
/usr/share/opensips/mysql
/usr/share/opensips/mysql/acc-create.sql
/usr/share/opensips/mysql/alias_db-create.sql
/usr/share/opensips/mysql/auth_db-create.sql
/usr/share/opensips/mysql/avpops-create.sql
/usr/share/opensips/mysql/b2b-create.sql
/usr/share/opensips/mysql/b2b_sca-create.sql
/usr/share/opensips/mysql/cachedb_sql-create.sql
/usr/share/opensips/mysql/call_center-create.sql
/usr/share/opensips/mysql/carrierroute-create.sql
/usr/share/opensips/mysql/closeddial-create.sql
/usr/share/opensips/mysql/clusterer-create.sql
/usr/share/opensips/mysql/cpl-create.sql
/usr/share/opensips/mysql/dialog-create.sql
/usr/share/opensips/mysql/dialplan-create.sql
/usr/share/opensips/mysql/dispatcher-create.sql
/usr/share/opensips/mysql/domain-create.sql
/usr/share/opensips/mysql/domainpolicy-create.sql
/usr/share/opensips/mysql/drouting-create.sql
/usr/share/opensips/mysql/emergency-create.sql
/usr/share/opensips/mysql/fraud_detection-create.sql
/usr/share/opensips/mysql/group-create.sql
/usr/share/opensips/mysql/imc-create.sql
/usr/share/opensips/mysql/load_balancer-create.sql
/usr/share/opensips/mysql/msilo-create.sql
/usr/share/opensips/mysql/permissions-create.sql
/usr/share/opensips/mysql/presence-create.sql
/usr/share/opensips/mysql/registrant-create.sql
/usr/share/opensips/mysql/registrar-create.sql
/usr/share/opensips/mysql/rls-create.sql
/usr/share/opensips/mysql/rtpproxy-create.sql
/usr/share/opensips/mysql/siptrace-create.sql
/usr/share/opensips/mysql/speeddial-create.sql
/usr/share/opensips/mysql/standard-create.sql
/usr/share/opensips/mysql/tls_mgm-create.sql
/usr/share/opensips/mysql/uri_db-create.sql
/usr/share/opensips/mysql/userblacklist-create.sql
/usr/share/opensips/mysql/usrloc-create.sql
/usr/share/doc/opensips-mysql-module/changelog.Debian.gz

Linux distribution

# uname -a
Linux dong 4.15.0-72-generic #81-Ubuntu SMP Tue Nov 26 12:20:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Python version

# python3 --version
Python 3.6.9
liviuchircu commented 4 years ago

The opensips-cli CLI tool just hangs during execution if opensips service is running in background. I tried to re-install opensips-cli but this didn't solve the issue. Then I stopped opensips service and run CLI tool again, it worked!

Interesting - so I guess this is the only problem left. Can you set log_level: DEBUG in your ~/.opensips-cli.cfg file, try again and paste the logs? I suspect it's getting stuck while communicating through /tmp/opensips_fifo, but I can't tell the reason.

PS: Thanks to your report, I pushed a fix for Python 3.5 users as well, so database create should work fine for them now :)

zhongdongy commented 4 years ago

The opensips-cli CLI tool just hangs during execution if opensips service is running in background. I tried to re-install opensips-cli but this didn't solve the issue. Then I stopped opensips service and run CLI tool again, it worked!

Interesting - so I guess this is the only problem left. Can you set log_level: DEBUG in your ~/.opensips-cli.cfg file, try again and paste the logs? I suspect it's getting stuck while communicating through /tmp/opensips_fifo, but I can't tell the reason.

PS: Thanks to your report, I pushed a fix for Python 3.5 users as well, so database create should work fine for them now :)

Glad to help! Just now I added log_level=DEBUG in the opensips-cli.cfg file (mine is under /etc/opensips/opensips-cli.cfg) and tried to run opensips-cli -x database create. Here is the output:

# opensips-cli -x database create
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: Loaded module 'mi'
DEBUG: sent command ':opensips_fifo_reply_4438:{"jsonrpc": "2.0", "id": "30125", "method": "which", "params": []}'

And I also tried other commands, similar output here:

# opensips-cli # No other arguments given here
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: Loaded module 'mi'
DEBUG: sent command ':opensips_fifo_reply_32218:{"jsonrpc": "2.0", "id": "18183", "method": "which", "params": []}'

So I think you are right, it stuck when communicating throught /tmp/opensips_fifo.


And just for your information, I also tried to add new domain via OpenSIPS control panel but failed. Do you think this can also because the MI interfaces stuck?

liviuchircu commented 4 years ago

Are you sure you have loaded the mi_fifo.so module? Maybe you have some old /tmp/opensips_fifo file -- could be a theory

liviuchircu commented 4 years ago

And just for your information, I also tried to add new domain via OpenSIPS control panel but failed. Do you think this can also because the MI interfaces stuck?

Yes, could be the same problem. After adding a new domain, the CP will reload the domains by writing ... domain_reload ... to /tmp/opensips_fifo, then waiting for a reply.

zhongdongy commented 4 years ago

Are you sure you have loaded the mi_fifo.so module? Maybe you have some old /tmp/opensips_fifo file -- could be a theory

Just now I checked my /etc/opensips/opensips.cfg file and the mi_fifo.so module is in the config and not commented. And the /tmp/opensips_fifo file is most recent (I deleted the old one and created again) but the opensips-cli still stuck at the same place.

# cat /etc/opensips/opensips.cfg | grep mi_fifo.so
loadmodule "mi_fifo.so"

# rm /tmp/opensips_fifo
# systemctl restart opensips
# ls /tmp/opensips_fifo -l
prw-rw-rw- 1 opensips opensips 0 Apr  3 15:57 /tmp/opensips_fifo
# opensips-cli
Welcome to OpenSIPS Command Line Interface!
DEBUG: Loaded module 'database'
DEBUG: Loaded module 'diagnose'
DEBUG: Loaded module 'instance'
DEBUG: Loaded module 'mi'
DEBUG: sent command ':opensips_fifo_reply_4488:{"jsonrpc": "2.0", "id": "28611", "method": "which", "params": []}'
^CTraceback (most recent call last):
  File "/usr/local/bin/opensips-cli", line 4, in <module>
    __import__('pkg_resources').run_script('opensipscli==0.1.0', 'opensips-cli')
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1438, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 9, in <module>
    run_console()
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/EGG-INFO/scripts/opensips-cli", line 6, in run_console
    main.main()
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/main.py", line 77, in main
    shell = cli.OpenSIPSCLIShell(args)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 84, in __init__
    self.update_instance(cfg.current_instance)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/cli.py", line 159, in update_instance
    self.modules[name] = (imod, mod.__get_methods__(imod))
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/modules/mi.py", line 181, in __get_methods__
    return comm.execute('which')
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/comm.py", line 40, in execute
    ret = comm_handler.execute(cmd, params)
  File "/usr/local/lib/python3.6/dist-packages/opensipscli-0.1.0-py3.6.egg/opensipscli/communication/fifo.py", line 63, in execute
    with open(reply_fifo_file, 'r') as reply_fifo:
KeyboardInterrupt
liviuchircu commented 4 years ago

Wait - are you sure that systemctl restart opensips doesn't start some OpenSIPS 2.4 package that's also installed on the system? It really looks like you're starting a 2.4 version, since it cannot process the /tmp/opensips_fifo data...

zhongdongy commented 4 years ago

Wait - are you sure that systemctl restart opensips doesn't start some OpenSIPS 2.4 package that's also installed on the system? It really looks like you're starting a 2.4 version, since it cannot process the /tmp/opensips_fifo data...

Oh no!! Indeed, the opensips has a version number of 2.2.2. I just checked with -V parameter:

# opensips -V
version: opensips 2.2.2 (x86_64/linux)
flags: STATS: On, DISABLE_NAGLE, USE_MCAST, SHM_MMAP, PKG_MALLOC, F_MALLOC, FAST_LOCK-ADAPTIVE_WAIT
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024, BUF_SIZE 65535
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
main.c compiled on  with gcc 7

And I upgraded it to opensips/stretch 3.0.2-1 amd64 [upgradable from: 2.2.2-3build4] via apt. Now it is working! The only thing left for me is to get the panel working. I might need to adjust some configurations.

Look how stupid I am! I'm really sorry for wasting your time! And thank you very much!

liviuchircu commented 4 years ago

<3 all good

PS: you're not the first "stupid" person who's done this, trust me... I would know best :D