Manticore PHP PDO | Communication link failure: 1047 unknown command (code=22)

943 Views Asked by At

After restarting the server (Centos7) I can't seem to connect to the Manticore with MySQL anymore. Searched for several hours now and tried many things, nothing worked so far. Requesting the status of searchd gives an error about a port to specify, though it is specified in the conf file. Anyone has a clue?


manticore.conf

searchd {
  listen = 127.0.0.1:9308:sphinx
  listen = 127.0.0.1:9306:mysql41
  log = searchd.log
  pid_file = manticoresearch.pid
}

cmd: searchd --config manticore.conf --stop

Manticore 4.2.0 15e927b@211223 release (columnar 1.11.4 327b3d4@211223)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2021, Manticore Software LTD (https://manticoresearch.com)

[06:21.497] [4921] using config file 'manticore.conf' (2212 chars)...
[06:21.498] [4921] stop: successfully sent SIGTERM to pid 3731

php pdo connection result: Connection failed: SQLSTATE[HY000] [2002] Connection refused


cmd: searchd --config manticore.conf

Manticore 4.2.0 15e927b@211223 release (columnar 1.11.4 327b3d4@211223)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2021, Manticore Software LTD (https://manticoresearch.com)

[54:45.655] [3728] using config file 'manticore.conf' (2249 chars)...
starting daemon version '4.2.0 15e927b@211223 release (columnar 1.11.4 327b3d4@211223)' ...
listening on 127.0.0.1:9308 for sphinx (to connect from SphinxSE)
listening on 127.0.0.1:9306 for mysql
precaching index 'companies'
precached 1 indexes in 0.002 sec

php pdo connection result: SQLSTATE[08S01]: Communication link failure: 1047 unknown command (code=22)


cmd: searchd --config manticore.conf --status

Manticore 4.2.0 15e927b@211223 release (columnar 1.11.4 327b3d4@211223)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)
Copyright (c) 2017-2021, Manticore Software LTD (https://manticoresearch.com)

[58:44.228] [4127] using config file 'manticore.conf' (2212 chars)...
[58:44.230] [4127] FATAL: failed to connect to daemon: please specify listen with sphinx protocol in your config file

searchd.log

[Fri Dec 31 10:54:45.658 2021] [3730] watchdog: main process 3731 forked ok
[Fri Dec 31 10:54:45.659 2021] [3731] starting daemon version '4.2.0 15e927b@211223 release (columnar 1.11.4 327b3d4@211223)' ...
[Fri Dec 31 10:54:45.659 2021] [3731] listening on 127.0.0.1:9308 for sphinx (to connect from SphinxSE)
[Fri Dec 31 10:54:45.660 2021] [3731] listening on 127.0.0.1:9306 for mysql
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: replaying log /var/run/manticore//binlog.001
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: replay stats: 0 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 0 indexes
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: finished replaying /var/run/manticore//binlog.001; 0.0 MB in 0.000 sec
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: replaying log /var/run/manticore//binlog.001
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: replay stats: 0 commits; 0 updates, 0 reconfigure; 0 pq-add; 0 pq-delete; 0 pq-add-delete, 0 indexes
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: finished replaying /var/run/manticore//binlog.001; 0.0 MB in 0.000 sec
[Fri Dec 31 10:54:45.675 2021] [3737] binlog: finished replaying total 2 in 0.000 sec
[Fri Dec 31 10:54:45.676 2021] [3732] prereading 1 indexes
[Fri Dec 31 10:54:45.676 2021] [3731] accepting connections
[Fri Dec 31 10:54:45.678 2021] [3732] prereaded 1 indexes in 0.003 sec
4

There are 4 best solutions below

0
Volpacchiotto On

it seems that PHP doesn't connect to 9308 or 9306 port which is reserved by Manticore, and that's why MySQL doesn't understand its command "MATCH". I've met this problem but still dunno what to do :( P.S. I've got this problem with Windows, but with CentOS 8 it works properly

0
barryhunter On

Many mysql Clients will bypass a TCP connection, if there is a 'socket' connection available.

ie the client, finds the mysql socket file, and connects directly, effectively ignoring the 'port' that would allow it connect to searchd as opposed to mysqld

This optimization usually happens if the host defined as 'localhost'.

If you use '127.0.0.1' as the 'hostname' in the PDO connection, it should ignore the socket file, and hence use the TCP port to connect to searchd.

0
Volpacchiotto On

I tried with official PHP library https://github.com/manticoresoftware/manticoresearch-php and framework connects to Manticore without errors

0
Volpacchiotto On

my solution works in CentOS 8 and Windows:

$connection = new \PDO('mysql:host=127.0.0.1;port=9306');

try also hosts 0 and localhost and port 9308

$result = $connection
->query('SELECT MAX(id) FROM my_index')
->fetch();

or

$result = $connection
->prepare('DELETE from my_index')
->execute();

$connection = null;//close connection