[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openser-users
Subject:    Re: [SR-Users] URL problems connecting to external	(Azure)	MySQL	database
From:       Samuel F. <samuel_is_kewl () hotmail ! com>
Date:       2017-11-27 21:19:20
Message-ID: DM5PR17MB098615CD19F59C617D707DB8C3250 () DM5PR17MB0986 ! namprd17 ! prod ! outlook ! com
[Download RAW message or body]

Hi again,


Reviewing the source for the parsing function it looks like it won't be pos=
sible.


https://github.com/kamailio/kamailio/blob/5295a4f5eac08c1bb100bf554a995833c=
434c4dc/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 as=
sume 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@cloud=
db.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 b=
e 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 possibl=
e.


// 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 d=
atabase


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 S=
amuel 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 d=
atabase



Hey,



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



// Samuel

________________________________

From: sr-users <sr-users-bounces@lists.kamailio.org<mailto:sr-users-bounces=
@lists.kamailio.org>> on behalf of Floimair Florian <f.floimair@commend.com=
<mailto: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 datab=
ase



Hi!



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

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



A somewhat unusual thing about the connection to a MySQL database on Azure =
is that the username contains an =91@=92 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.mys=
ql.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 po=
ol

ERROR: sipcapture [sipcapture.c:1146]: child_init(): unable to connect to d=
atabase [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=FC=DFen

Florian Floimair (IMS) 1568





[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} \
--></style> </head>
<body dir="ltr">
<div id="divtagdefaultwrapper" \
style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" \
dir="ltr"> <p style="margin-top:0;margin-bottom:0">Hi again,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Reviewing the source for the parsing function \
it looks like it won't be possible.</p> <p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><a \
href="https://github.com/kamailio/kamailio/blob/5295a4f5eac08c1bb100bf554a995833c434c4dc/src/modules/db_mysql/my_uri.c#L147" \
class="OWAAutoLink" id="LPlnk526631" \
previewremoved="true">https://github.com/kamailio/kamailio/blob/5295a4f5eac08c1bb100bf554a995833c434c4dc/src/modules/db_mysql/my_uri.c#L147</a></p>
 <br>
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. <div><br>
</div>
<div>In your case the host will be: clouddb and the port will \
be:&nbsp;<span>password@clouddb.mysql.database.azure.com</span></div> <div><span><br>
</span></div>
<div><span>Have you checked the docs under section 6?:&nbsp;
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, \
&quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 15px; margin-top: \
0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);">6. Reading \
configuration from my.cnf</pre> <pre style="box-sizing: border-box; font-family: \
SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; \
font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: \
rgb(36, 41, 46);"><br></pre> <pre style="box-sizing: border-box; font-family: \
SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; \
font-size: 15px; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; color: \
rgb(36, 41, 46);">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.</pre> <pre \
style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, \
&quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 15px; margin-top: \
0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);"><br></pre> \
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, \
&quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 15px; margin-top: \
0px; margin-bottom: 0px; white-space: pre-wrap; color: rgb(36, 41, 46);">Also, feel \
free to submit a patch for the above parsing function if possible.</pre> \
</span></div> <div><br>
<p></p>
<p style="margin-top:0;margin-bottom:0">// Samuel</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" \
style="font-size:11pt" color="#000000"><b>From:</b> sr-users \
&lt;sr-users-bounces@lists.kamailio.org&gt; on behalf of Floimair Florian \
&lt;f.floimair@commend.com&gt;<br> <b>Sent:</b> Monday, November 27, 2017 4:47:52 \
PM<br> <b>To:</b> Kamailio (SER) - Users Mailing List<br>
<b>Subject:</b> Re: [SR-Users] URL problems connecting to external (Azure) MySQL \
database</font> <div>&nbsp;</div>
</div>
<style>
<!--
@font-face
	{font-family:"Cambria Math"}
@font-face
	{font-family:Calibri}
@font-face
	{font-family:Hack}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif}
a:x_link, span.x_MsoHyperlink
	{color:#0563C1;
	text-decoration:underline}
a:x_visited, span.x_MsoHyperlinkFollowed
	{color:#954F72;
	text-decoration:underline}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif}
p.x_xmsochpdefault, li.x_xmsochpdefault, div.x_xmsochpdefault
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif}
span.x_xe-mailformatvorlage17
	{font-family:"Calibri",sans-serif;
	color:windowtext}
span.x_E-MailFormatvorlage23
	{font-family:"Calibri",sans-serif;
	color:windowtext}
.x_MsoChpDefault
	{font-size:10.0pt}
@page WordSection1
	{margin:70.85pt 70.85pt 2.0cm 70.85pt}
div.x_WordSection1
	{}
-->
</style>
<div lang="DE" link="#0563C1" vlink="#954F72">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span lang="EN-US" style="">Thanks for your quick \
reply!</span></p> <p class="x_MsoNormal"><span lang="EN-US" \
style="">&nbsp;</span></p> <p class="x_MsoNormal"><span lang="EN-US" \
style="">Unfortunately the result is exactly the same error.</span></p> <p \
class="x_MsoNormal"><span lang="EN-US" style="">&nbsp;</span></p> <div>
<p class="x_MsoNormal" style=""><span lang="EN-US" style="font-size:12.0pt; \
font-family:&quot;Times New Roman&quot;,serif">&nbsp;</span></p> <p \
class="x_MsoNormal" style=""><span lang="EN-US" style="font-size:12.0pt; \
font-family:&quot;Times New Roman&quot;,serif">&nbsp;</span></p> <p \
class="x_MsoNormal"><span lang="EN-US" style="font-size:10.0pt; \
font-family:&quot;Arial&quot;,sans-serif; color:black">With best regards</span></p> \
<p class="x_MsoNormal"><span lang="EN-US" style="font-size:10.0pt; \
font-family:&quot;Arial&quot;,sans-serif; color:black"><br> </span><b><span \
lang="EN-US" style="font-size:10.0pt; font-family:&quot;Arial&quot;,sans-serif; \
color:black">Florian Floimair<br> <br>
</span></b><span lang="EN-US" style="font-size:12.0pt; font-family:&quot;Times New \
Roman&quot;,serif"></span></p> </div>
<p class="x_MsoNormal"><span lang="EN-US" style="">&nbsp;</span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_MsoNormal"><b>Von:</b> sr-users \
[mailto:sr-users-bounces@lists.kamailio.org] <b>Im Auftrag von </b>Samuel F.<br>
<b>Gesendet:</b> Montag, 27. November 2017 16:04<br>
<b>An:</b> Kamailio (SER) - Users Mailing List \
&lt;sr-users@lists.kamailio.org&gt;<br> <b>Betreff:</b> Re: [SR-Users] URL problems \
connecting to external (Azure) MySQL database</p> </div>
</div>
<p class="x_MsoNormal">&nbsp;</p>
<div id="x_divtagdefaultwrapper">
<p><span style="font-size:12.0pt; color:black">Hey,</span></p>
<p><span style="font-size:12.0pt; color:black">&nbsp;</span></p>
<p><span style="font-size:12.0pt; color:black">Could you try replacing the @-sign in \
the username with: %40&nbsp; (percent-forty)?</span></p> <p><span \
style="font-size:12.0pt; color:black">&nbsp;</span></p> <p><span \
style="font-size:12.0pt; color:black">// Samuel</span></p> </div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span \
style="color:black"> sr-users &lt;<a \
href="mailto:sr-users-bounces@lists.kamailio.org">sr-users-bounces@lists.kamailio.org</a>&gt; \
on behalf of Floimair Florian &lt;<a \
href="mailto:f.floimair@commend.com">f.floimair@commend.com</a>&gt;<br> <b>Sent:</b> \
Monday, November 27, 2017 3:33:21 PM<br> <b>To:</b> Kamailio (SER) - Users Mailing \
List<br> <b>Subject:</b> [SR-Users] URL problems connecting to external (Azure) MySQL \
database</span> </p>
<div>
<p class="x_MsoNormal">&nbsp;</p>
</div>
</div>
<div>
<div>
<p class="x_xmsonormal">Hi!</p>
<p class="x_xmsonormal">&nbsp;</p>
<p class="x_xmsonormal"><span lang="EN-US">I’m having troubles connecting Kamailio to \
an external MySQL database (on Microsoft Azure Cloud).</span></p> <p \
class="x_xmsonormal"><span lang="EN-US">Initially creating the database with kamctl \
worked fine, but accessing it at runtime via db_url fails.</span></p> <p \
class="x_xmsonormal"><span lang="EN-US">&nbsp;</span></p> <p \
class="x_xmsonormal"><span lang="EN-US">A somewhat unusual thing about the connection \
to a MySQL database on Azure is that the username contains an ‘@’ \
character.</span></p> <p class="x_xmsonormal"><span lang="EN-US">This leads me to \
believe that this case is somewhat unhandled when parsing the database \
URI.</span></p> <p class="x_xmsonormal"><span lang="EN-US">&nbsp;</span></p>
<p class="x_xmsonormal"><span lang="EN-US">Trying to connect to something \
like</span></p> <p class="x_xmsonormal"><span lang="EN-US">&nbsp;</span></p>
<p class="x_xmsonormal"><span lang="EN-US" style="font-size:10.0pt; \
font-family:Hack">modparam(&quot;sipcapture&quot;, &quot;db_url&quot;, \
&quot;mysql://user@clouddb:password@clouddb.mysql.database.azure.com/db&quot;)</span></p>
 <p class="x_xmsonormal"><span lang="EN-US">&nbsp;</span></p>
<p class="x_xmsonormal"><span lang="EN-US">Results in errors starting \
Kamailio</span></p> <p class="x_xmsonormal"><span lang="EN-US">&nbsp;</span></p>
<p class="x_xmsonormal" style="text-autospace:none"><span lang="EN-US" \
style="font-size:10.0pt; font-family:Hack; color:#CB4B16">ERROR: db_mysql \
[km_my_con.c:124]: db_mysql_new_connection(): driver error: Unknown MySQL server host \
'clouddb' (-2)</span></p> <p class="x_xmsonormal" style="text-autospace:none"><span \
lang="EN-US" style="font-size:10.0pt; font-family:Hack; color:#CB4B16">ERROR: \
&lt;core&gt; [db.c:318]: db_do_init2(): could not add connection to the \
pool</span></p> <p class="x_xmsonormal"><span lang="EN-US" style="font-size:10.0pt; \
font-family:Hack; color:#CB4B16">ERROR: sipcapture [sipcapture.c:1146]: child_init(): \
unable to connect to database [<a \
href="">mysql://user@clouddb:password@clouddb.mysql.database.azure.com/db</a>]  from \
capture_mode param.</span></p> <p class="x_xmsonormal"><span lang="EN-US" \
style="color:black">Is there a trick on how to achieve a connection in this case like \
some sort of escape character probably?</span></p> <p class="x_xmsonormal"><span \
lang="EN-US" style="font-size:10.0pt; font-family:&quot;Arial&quot;,sans-serif; \
color:black">&nbsp;</span></p> <p class="x_xmsonormal"><span lang="EN-US" \
style="font-size:10.0pt; font-family:&quot;Arial&quot;,sans-serif; \
color:black">&nbsp;</span></p> <p class="x_xmsonormal"><span lang="DE-AT" \
style="font-size:10.0pt; font-family:&quot;Arial&quot;,sans-serif; color:black">Mit \
freundlichen Grüßen<br> <br>
<b>Florian Floimair (IMS) 1568</b></span></p>
<p class="x_xmsonormal"><span lang="DE-AT" style="font-size:12.0pt; \
font-family:&quot;Times New Roman&quot;,serif">&nbsp;</span></p> <p \
class="x_xmsonormal">&nbsp;</p> </div>
</div>
</div>
</div>
</body>
</html>


[Attachment #4 (unknown)]

_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic