MySQL X Protocol Plugin not listening (All routers failed)

0

1

I am trying to set up and test the MySQL X Protocol (related keywords: MySQLX, X Plugin, XDevAPI, Connector/Node.js) and it somehow doesn't run as expected.

I am running Windows 7 64 Bit with a MySQL 5.7 service. I have made sure the X Protocol is running and listening by executing the following commands (after installing MySQL Shell).

mysqlsh.exe -u root -h localhost --classic --dba enableXProtocol
Creating a Classic Session to 'root@localhost'
Enter password: ************************
Your MySQL connection id is 14
Server version: 5.7.19-log MySQL Community Server (GPL)
No default schema selected; type \use <schema> to set one.
enableXProtocol: X Protocol plugin is already enabled and listening for connections on port 33060

mysqlsh.exe -u root --sqlc -e "show plugins"
Enter password: ************************
+----------------------------+----------+--------------------+---------+---------+
| Name                       | Status   | Type               | Library | License |
+----------------------------+----------+--------------------+---------+---------+
| binlog                     | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| mysql_native_password      | ACTIVE   | AUTHENTICATION     | null    | GPL     |
| sha256_password            | ACTIVE   | AUTHENTICATION     | null    | GPL     |
| CSV                        | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| MEMORY                     | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| InnoDB                     | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| INNODB_TRX                 | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_LOCKS               | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_LOCK_WAITS          | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_CMP                 | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_CMP_RESET           | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_CMPMEM              | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_CMPMEM_RESET        | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_CMP_PER_INDEX       | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_BUFFER_PAGE         | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_BUFFER_PAGE_LRU     | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_BUFFER_POOL_STATS   | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_TEMP_TABLE_INFO     | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_METRICS             | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_FT_DELETED          | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_FT_BEING_DELETED    | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_FT_CONFIG           | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_FT_INDEX_CACHE      | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_FT_INDEX_TABLE      | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_TABLES          | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_TABLESTATS      | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_INDEXES         | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_COLUMNS         | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_FIELDS          | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_FOREIGN         | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_FOREIGN_COLS    | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_TABLESPACES     | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_DATAFILES       | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| INNODB_SYS_VIRTUAL         | ACTIVE   | INFORMATION SCHEMA | null    | GPL     |
| MyISAM                     | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| MRG_MYISAM                 | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| PERFORMANCE_SCHEMA         | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| ARCHIVE                    | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| BLACKHOLE                  | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| FEDERATED                  | DISABLED | STORAGE ENGINE     | null    | GPL     |
| partition                  | ACTIVE   | STORAGE ENGINE     | null    | GPL     |
| ngram                      | ACTIVE   | FTPARSER           | null    | GPL     |
| mysqlx                     | ACTIVE   | DAEMON             | mysqlx  | GPL     |
+----------------------------+----------+--------------------+---------+---------+

However, the following command outputs nothing (I also checked the output manually without grep):

E:\>netstat -a -b | grep 33060

Which is the main reason why I post this on SuperUser and not StackOverflow. I think it is not a programming error. For the sake of completeness I will include the small Javascript I have used to test my connection from Node.js inspired by the official database connection example.

const mysqlx = require('@mysql/xdevapi');

async function main()
{
    const session = await mysqlx.getSession({
        host: 'localhost',
        port: 33060,
        dbUser: 'test',
        dbPassword: 'test',
    });
    console.log(session);
}

main().catch(function (error) { console.log("error caught in main routine\n", error); });

The output is the following:

$ node db.js
error caught in main routine
 { Error: All routers failed.
    at Session._failover (E:\temporary\xdevapi\node_modules\@mysql\xdevapi\lib\DevAPI\Session.js:231:23)
    at _properties.socketFactory.createSocket.then.then.then.then.catch.err (E:\temporary\xdevapi\node_modules\@mysql\xdevapi\lib\DevAPI\Session.js:271:27)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7) errno: 4001 }

The MySQL server is running as a service on my computer. The database is working fine. Any ideas why MySQL thinks the plugin is listening, while it actually isn't? Or is the netstat command I run not the right one for this job? How can I fix this problem?

Neonit

Posted 2017-09-28T16:14:15.770

Reputation: 183

Answers

0

netstat was actually working fine.

A way of checking whether the Mysqlx plugin was listening on the port it's supposed to listen on is checking the MySQL status variables.

SHOW GLOBAL STATUS

According to the official MySQL 5.7 reference there should be a variable named Mysqlx_port set to the respective port. If it's set to UNDEFINED the binding has failed. This was the case for me.

Long story short, I uninstalled everything with MySQL in its name after exporting my data and reinstalled it. After that I made sure the vanilla server would listen to 33060 now and it did.

However, after copying my Data folder to the new server's data directory (C:/ProgramData/MySQL Server 5.7/), it stopped working again. I reset the database again and imported the data using a SQL dump. The problem came back again.

I needed to restore my old database, then export only my databases (without mysql, sys, performance_schema and information_schema) and import them in the new database to have it work properly. It appears there's some setting or data in the server databases that prevents Mysqlx from working properly.

Pro tip for exporting all data: Use

mysqldump -u root -p --routines --triggers --databases <database>... > dump.sql

So it will export routines and triggers as well. Users will be lost as well, but there are threads on the internet with explanations on how to do it. The command will prompt for a password.

Use this to reimport:

mysql -u root -p < dump.sql

Neonit

Posted 2017-09-28T16:14:15.770

Reputation: 183