Hi again,


Reviewing the source for the parsing function it looks like it won't be possible.


https://github.com/kamailio/kamailio/blob/5295a4f5eac08c1bb100bf554a995833c434c4dc/src/modules/db_mysql/my_uri.c#L147


We see that once it hits the @, if it hasn't hit a : or / before it will assume everything to the left of the @ is the username and then it will start to parse everything to the right of the @ as the hostname.

In your case the host will be: clouddb and the port will be: password@clouddb.mysql.database.azure.com

Have you checked the docs under section 6?: 
6. Reading configuration from my.cnf

Not sure how that is implemented to fetch the data but that might perhaps be a way to get around the parsing structure in the mysql module.

Also, feel free to submit a patch for the above parsing function if possible.

// Samuel



From: sr-users <sr-users-bounces@lists.kamailio.org> on behalf of Floimair Florian <f.floimair@commend.com>
Sent: Monday, November 27, 2017 4:47:52 PM
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] URL problems connecting to external (Azure) MySQL database
 

Thanks for your quick reply!

 

Unfortunately the result is exactly the same error.

 

 

 

With best regards


Florian Floimair

 

Von: sr-users [mailto:sr-users-bounces@lists.kamailio.org] Im Auftrag von Samuel F.
Gesendet: Montag, 27. November 2017 16:04
An: Kamailio (SER) - Users Mailing List <sr-users@lists.kamailio.org>
Betreff: Re: [SR-Users] URL problems connecting to external (Azure) MySQL database

 

Hey,

 

Could you try replacing the @-sign in the username with: %40  (percent-forty)?

 

// Samuel


From: sr-users <sr-users-bounces@lists.kamailio.org> on behalf of Floimair Florian <f.floimair@commend.com>
Sent: Monday, November 27, 2017 3:33:21 PM
To: Kamailio (SER) - Users Mailing List
Subject: [SR-Users] URL problems connecting to external (Azure) MySQL database

 

Hi!

 

I’m having troubles connecting Kamailio to an external MySQL database (on Microsoft Azure Cloud).

Initially creating the database with kamctl worked fine, but accessing it at runtime via db_url fails.

 

A somewhat unusual thing about the connection to a MySQL database on Azure is that the username contains an ‘@’ character.

This leads me to believe that this case is somewhat unhandled when parsing the database URI.

 

Trying to connect to something like

 

modparam("sipcapture", "db_url", "mysql://user@clouddb:password@clouddb.mysql.database.azure.com/db")

 

Results in errors starting Kamailio

 

ERROR: db_mysql [km_my_con.c:124]: db_mysql_new_connection(): driver error: Unknown MySQL server host 'clouddb' (-2)

ERROR: <core> [db.c:318]: db_do_init2(): could not add connection to the pool

ERROR: sipcapture [sipcapture.c:1146]: child_init(): unable to connect to database [mysql://user@clouddb:password@clouddb.mysql.database.azure.com/db] from capture_mode param.

Is there a trick on how to achieve a connection in this case like some sort of escape character probably?

 

 

Mit freundlichen Grüßen

Florian Floimair (IMS) 1568