error 10106 connecting to mySQL through a Perl cgi

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
Andrewb
-


Joined: 01 Apr 2003
Posts: 6
Location: UK

PostPosted: Tue Apr 01, 2003 9:37 pm    Post subject: error 10106 connecting to mySQL through a Perl cgi Reply with quote

I am trying to install Movable Type (MT), which is a complex and powerful blogging system, written in Perl, on a Windows 2000 machine.

I have got the Abyss server running properly, and it will show the opeing MT screen, so it is runningperl CGI scripts as it should. HOWEVER the perl script cannot connect to MySQL. I have installed the necessary modules. Everything _looks_ just fine.
Whenever and whatever I try I get an error 10106, socket could not be opened.
Now, the same databsae has been running flawlessly for a year on this machine. I can acess it directly and over the network using a variety of front ends. So I know that the problem isn't with mySQL. Something I found through Google made me suspect that it might be a security problem -- I am running Abyss web server as a user, not an administrator; obviously, I can't run it as a service.
Is that any reason why the web server would have problems connecting to mySQL through a CGI process? Or is the whole thing a total mystery?
_________________
Andrew Brown
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Apr 02, 2003 12:37 am    Post subject: Re: error 10106 connecting to mySQL through a Perl cgi Reply with quote

Andrewb wrote:

Is that any reason why the web server would have problems connecting to mySQL through a CGI process? Or is the whole thing a total mystery?

The web server never connects to the database. It is your Perl interpreter that does that.
Well, after some searches on the internet, it seems that you are configured your script to access a wrong mysql port. By default the mysql port is 3306.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Andrewb
-


Joined: 01 Apr 2003
Posts: 6
Location: UK

PostPosted: Wed Apr 02, 2003 6:21 am    Post subject: Reply with quote

Thank you for replying so promptly.

The Perl thing is set up to 3306, so far as I can tell. That's the default port. Everything else connects on there. Indeed, I have another mySQL database set up on port 3333 (this is actually tunnelled through SSH to my web server) and I get the same error (10106) when I try to connect to that one, despite explicitly setting the port number to 3333.

I shall try to find a simple Perl script to connect to mySQL without CGI and see if that works.

The only reason I thought it might be a web server problem is that processes started by the web server might not have sufficient security privileges to access mySQL: this at any rate was the answer in an apparently similar problem someone had had with PHP, Abyss, and mySQL, according to Google.
_________________
Andrew Brown
Back to top View user's profile Send private message Visit poster's website
Andrewb
-


Joined: 01 Apr 2003
Posts: 6
Location: UK

PostPosted: Wed Apr 02, 2003 8:31 am    Post subject: Reply with quote

OK. I think now that it must be an aprelium problem, because I can get non-CGI code to work: if I just write little test script, like this:
Code:

use strict;
use DBI;

my $data_source = 'DBI:mysql:test:localhost';
my $db_user_name = 'myusername';
my $db_password = 'hahanotputtingthatontheweb';
my $dbh = DBI->connect($data_source, $db_user_name, $db_password)
        or die $DBI::errstr;
my $sth;

$sth = $dbh->prepare("SELECT Fullname,Email FROM email WHERE email like '%guardian%' ORDER BY Last_name");
$sth->execute();
print "Full Name, Email\n\n";
while(my ($fname,$email) = $sth->fetchrow_array)
{
        print "$fname : $email\n";
}
$sth->finish();
$dbh->disconnect();

It works, connecting to the database without fuss and retrieving the information I want. But when I try to run MT as a CGI from the Abyss server using exactly the same settings for the database, I get the 10106 error.
If I knew a little more Perl, I would try to convert the standalone script above (stolen from Google) into a CGI, so I could be absolutely sure that the problem was with CGI scripts only. But since MT runs perfectly well everywhere else, and this particular problem has not been reported on their boards, I think it must be a CGI problem at the Abyss end.
_________________
Andrew Brown
Back to top View user's profile Send private message Visit poster's website
Andrewb
-


Joined: 01 Apr 2003
Posts: 6
Location: UK

PostPosted: Wed Apr 02, 2003 9:43 am    Post subject: Reply with quote

Just to clinch it: I did convert the script above into a CGI, and, running it from the simplest possible test page, I got
Code:

Perl CGI test
Content-type: text/html
Software error:

Can't create TCP/IP socket (10106) at testperl.cgi line 15.
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

which is exactly the same error as MT has been giving me. So it must be a web server problem, and not a problem with perl or mySQL directly, since the same code makes the connection perfectly from a command line.

I can post the CGI script if you like, but it is identical -- give or take CGI features -- to the simple database script I posted above.

line 15, where the error is reported, is

Code:

my $dbh = DBI->connect($data_source, $db_user_name, $db_password)
        or die $DBI::errstr;

_________________
Andrew Brown
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu Apr 03, 2003 12:11 pm    Post subject: Reply with quote

Again Andrew, there is no connection between the web server and the database. This is technically impossible. Try running your simple Perl script on the command line and you will notice also that the problem occurs.
A search on google shows that many people had such a problem with Perl DBI and MySQL. So we can guess that it is some sort of common problem. Some people say that it is related to the Windows 2000 TCP/IP driver.
Anyway, we run our test machines on Windows2000 and we tested MT and never had such an error message.
By the way, have you asked the question to MT support?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Andrewb
-


Joined: 01 Apr 2003
Posts: 6
Location: UK

PostPosted: Thu Apr 03, 2003 2:02 pm    Post subject: Reply with quote

Quote:

Again Andrew, there is no connection between the web server and the database. This is technically impossible. Try running your simple Perl script on the command line and you will notice also that the problem occurs.

I'm sorry, but, as I said in an earlier message, I can and do run the script I posted as from the command line without any problems.

Only when it is run as a CGI under your web server do I get this error message. It has to be a problem with Abyss WS, not Perl or mySQL.

As a final proof of this, I downloaded and installed another web server, Sambar. It is about ten times the size of Abyss web server, and with a much less attractive interface. I'd rather use Abyss if I had the choice.

But Sambar has one huge advantage: it works with mySQL: both my test script and MT connect to mySQL without problems using Sambar. So even if your server does not connect directly with mySQL, it does somehow prevent my CGI scripts from connecting themselves.

I did google pretty extensively around the problem before troubling you with it. I did ask in the MT forums, and searched them to see if anyone else has had the same specific error message. No one answered my query there. I appreciate that you're giving a really nice program away and you don't need every passing idiot asking for tech support. But I am trying now to give you a helpful bug report.

The thing about MT is that you can run it without mySQL if you want to. In fact I think that's the default, and mySQL support was only introduced last year. So if you tested it without the mySQL connection, it probably works fine. But MT won't work under Abyss web Server with mySQL. Try it yourselves. In fact, if you can get any CGI script to connect to mySQL, when it is running as a service under Windows 2000, I will apologise with a flourish of grovels.
_________________
Andrew Brown
Back to top View user's profile Send private message Visit poster's website
Andrewb
-


Joined: 01 Apr 2003
Posts: 6
Location: UK

PostPosted: Mon Apr 21, 2003 12:30 pm    Post subject: Reply with quote

Ok. I finally solved this.

AWS will only run perl scripts that connect to mySQL if I start it as an administrator. Once I do that, MT works as it should. If I run it from my normal "power user" account, it won't. If, logged in as a power user, I run AWS as root, it works.

Is there any way I can automate the process?
_________________
Andrew Brown
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Apr 21, 2003 3:31 pm    Post subject: Reply with quote

Andrewb wrote:
Ok. I finally solved this.

AWS will only run perl scripts that connect to mySQL if I start it as an administrator. Once I do that, MT works as it should. If I run it from my normal "power user" account, it won't. If, logged in as a power user, I run AWS as root, it works.

Is there any way I can automate the process?

Search about how to run Abyss Web Server as a service in that forum. Some people managed to run Abyss in that mode with administrator privileges just using the available Windows tools.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group