[MXS-4058] Query Editor: Connection to [::]:9999 failed. Error 2002: Can't connect to server on '::' (113) Created: 2022-03-24  Updated: 2022-03-29  Resolved: 2022-03-29

Status: Closed
Project: MariaDB MaxScale
Component/s: maxgui
Affects Version/s: 6.2.1
Fix Version/s: 6.2.4, 22.08.0

Type: Bug Priority: Major
Reporter: Naresh Chandra Assignee: markus makela
Resolution: Fixed Votes: 0
Labels: None

Sprint: MXS-SPRINT-154

 Description   

In the Query editor, we are unable to connect the DB, if we select source as a Listener. But we are able to connect the DB, if we select source as a Server from the GUI.

We are getting the below error while trying to connect the DB using source a Listener [Schema-Service-Listener].

*Connection to [::]:9999 failed. Error 2002: Can't connect to server on '::' (113) *

Below is configuration file:

[maxscale]
threads                                 =       4
admin_host                              =       192.168.1.1
admin_port                              =       8080
auth_read_timeout                       =       10s
admin_secure_gui                        =       false
admin_pam_readonly_service              =       maxscale
 
[server1]
type                                    =       server
address                                 =       192.168.1.2
port                                    =       9999
proxy_protocol                          =       on
 
[server2]
type                                    =       server
address                                 =       192.168.1.3
port                                    =       9999
proxy_protocol                          =       on
 
[server3]
type                                    =       server
address                                 =       192.168.1.4
port                                    =       9999
proxy_protocol                          =       on
 
 
[Scehma-Router-Service]
type                                    =       service
router                                  =       schemarouter
servers                                 =       server1,server2,server3
user                                    =       max_user
password                                =       XXXXXXXXXXXXX
connection_timeout                      =       3000s
auth_all_servers                        =       true
 
[Schema-Service-Listener]
type                                    =       listener
service                                 =       Scehma-Router-Service
protocol                                =       mariadbclient
port                                    =       9999
authenticator                           =       PAMAuth
 
[Monitor]
type                                    =       monitor
module                                  =       mariadbmon
servers                                 =       server1,server2,server3
user                                    =       max_user
password                                =       XXXXXXXXXXXXX



 Comments   
Comment by Duong Thien Ly [ 2022-03-24 ]

Hi naresh.chandra@copart.com, are you able to connect to the listener via CLI? .e.g. `mariadb -h 127.0.0.1 -umaxskysql -pskysql -P9999`

Comment by Naresh Chandra [ 2022-03-24 ]

Hi Duong,

Yes, we are able to connect from the CLI.

Comment by markus makela [ 2022-03-28 ]

I think the problem might be in the SQL endpoint of the REST API: it probably uses the raw address string instead of checking whether it's the all-interfaces address of either 0.0.0.0 or ::.

Comment by Naresh Chandra [ 2022-03-28 ]

Hi Markus,

Thanks for the update. Can we fix this issue in the next release?

Comment by markus makela [ 2022-03-28 ]

naresh.chandra@copart.com can you test if it works correctly when you define the actual IP address of the host (e.g. 192.168.1.100 or whatever ip addr shows)?

Comment by Naresh Chandra [ 2022-03-28 ]

Markus, you mean, I should try like this mariadb -h 192.168.1.1 -umaxskysql -pskysql -P9999`

Comment by markus makela [ 2022-03-28 ]

Sorry, I wasn't clear enough: can you add address=192.168.1.1 (I'm assuming this is the IP of the machine) to the listeners and then test if the GUI works?

Comment by Naresh Chandra [ 2022-03-28 ]

Getting the below error.

Connection to [192.168.1.1]:9999 failed. Error 1524: Plugin 'mysql_native_password' is not loaded.

[Read_Listener]
type = listener
service = Read_Service
protocol = mariadbclient
port = 9999
address = 192.168.1.1
authenticator = PAMAuth

Comment by markus makela [ 2022-03-28 ]

Are you using version 6.2.1? If so, can you test this with 6.2.3 as well?

Comment by markus makela [ 2022-03-28 ]

Ah, you'll need to include mariadbauth in that authenticators list.

Comment by Naresh Chandra [ 2022-03-28 ]

Yes, I am using 6.2.1, let me try 6.2.3 and update you.

Comment by Naresh Chandra [ 2022-03-28 ]

Markus, I tried with 6.2.3 but still the issue is same.

Comment by markus makela [ 2022-03-28 ]

did it work with authenticators=PAMAuth,MariaDBAuth?

Comment by Naresh Chandra [ 2022-03-28 ]

Both are not working.

Comment by markus makela [ 2022-03-28 ]

What error does it return when you add authenticators=PamAuth,Mariadbauth to the listeners and use the correct IP address?

Comment by Naresh Chandra [ 2022-03-28 ]

If we use the authenticators=Mariadbauth then we are getting the below error

ERROR 1045 (28000): Access denied for user

If we use the authenticators=Mariadbauth then we are getting the below error
Connection to [192.168.1.1]:9999 failed. Error 1524: Plugin 'mysql_native_password' is not loaded.

Comment by markus makela [ 2022-03-28 ]

You'll need a user that is allowed to connect from the local host, i.e. user@127.0.0.1. Once you add that and use authenticators=mariadbauth,pamauth I think it should work.

Comment by Naresh Chandra [ 2022-03-28 ]

You mean, I have to create an user locally in mariadb then I need to add the parameter in the maxscale config file right?

and can you confirm/check that Maxscale Query editor rest API is same for Server and Listener? I mean if we select in the GUI, source as either server and listener then the API call is same or its different logic in the code?

Comment by markus makela [ 2022-03-28 ]

Internally, the code creates a new connection and the only difference is the address to which the connection is created: for listeners it is a local connection whereas for servers it is a remote one. For this reason you must have a user that has the permission to log in from the "local" server, i.e. from 127.0.0.1.

To create the local user, you can create it similar to this:

CREATE USER 'user'@'127.0.0.1' IDENTIFIED BY 'my-password';

Obviously, change the username and password to what is suitable for you. Please also note that in order for MaxScale to be able to connect to the databases, the same user must also have the grants for direct access. Optionally, you could enable proxy_protocol to avoid creating the second user definition.

Comment by Naresh Chandra [ 2022-03-28 ]

Ok Markus,

Are you changing anything to related Server(source) or Listener(Source) API? But keep same settings for Server(source) API code as its working fine.

Comment by markus makela [ 2022-03-28 ]

We could make it so that if the listener uses address=0.0.0.0 or address=::, MaxScale would correctly translate this to address=localhost for the GUI SQL connections. You can confirm whether this would solve your problem by following the instructions I've written to use the actual IP address of the MaxScale host. Based on the fact that you got an access denied error, I would say that this would solve the problem once the correct user permissions are added.

Comment by Naresh Chandra [ 2022-03-28 ]

Yeah, I got it Markus, But not sure where i am facing the error. Better keep the same settings for Server (Source) code. So I think we can close this ticket. We will use source as a Server only. But here we are expecting the global or local browser cache if we select source as a server.

Generated at Thu Feb 08 04:25:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.