Page 1 of 2

Connecting via HTTP tunnel by PHP - libmysql.dll error

Posted: Tue 06 Apr 2010 13:55
by dataquest
Hi!
I get this error when I'm trying to connect to database using http tunnel:

"MySQL client library couldn't be loaded. Please place libmysql.dll file to system folder (included to PATH) or to the folder with executable unit of main program."

My configuration of TMyConnection looks like this:
HttpOptions / Url = http://www.mydomain.com/tunnel.php
Options / Protocol = mpHttp
Port: 3306
Server: localhost

File tunnel.php is placed on server and it generates some entries on _connections.id.

My operation system is Windows 7 x64.
I also have the newest version of libmysql.dll In the system folder and the project folder.

Any ideas?

Posted: Wed 07 Apr 2010 08:42
by Dimon
To solve this problem try to use the Direct mode to connect to MySQL database. For this the TMyConnection.Options.Direct property to True.

Posted: Wed 07 Apr 2010 10:17
by dataquest
Thanks for reply!

I set "Direct" property to "True" but still no luck.

New error message:
"Lost connection to MySQL server during query
Socket error on read. WSAGetLastError return 10060($274C)."

Posted: Wed 07 Apr 2010 11:45
by Dimon
The php script must be available through the HTTP protocol. Please verify if it is accessible for a web. For this enter the http://www.mydomain.com/tunnel.php address to a web browser and check the result.

Posted: Thu 08 Apr 2010 09:24
by dataquest
The php script is available through the HTTP protocol.
When I use it's address in borwser I get this message:
"HttpTunnel v1.5
Tunnel script is installed correctly.
You can establish connections through the HTTP tunnel."

I even tried to install script on another machine in my local network (http://192.168.0.3/tunnel.php) - still the same error:

"Can't connect to MySQL server on 'localhost' (10061)
Socket error on read. WSAGetLastError return 10060($274C)."


This is detailed configuration of my TMyConnection component:

ConnectDialog =
ConnectionTimeout = 15
Database = tunnel
HttpOptions / Password =
ProxyOptions = (...all options are set to default)
HttpOptions / Url = http://192.168.0.3/tunnel.php
HttpOptions / Username =
IOHandler =
IsolationLevel = ilReadCommited
Options / CheckBackslashes = False
Options / Compress = False
Options / Direct = True
Options / DisconnectedMode = False
Options / Embedded = False
Options / LocalFailover = False
Options / Protocol = mpHttp
Password = mypassword
Pooling = False
Port = 3306
Server = localhost
SSLOptions = (...all options are set to default)
Username = myusername


Any ideas?

Posted: Thu 08 Apr 2010 14:27
by Dimon
This error is arised because php script doesn't have access to MySQL server on computer, where it is executed, or MySQL server is installed on a different machine. To solve the problem try to specify the full address of MySQL server in the Server property.

Posted: Fri 09 Apr 2010 10:22
by dataquest
Dimon, please try to connect to our public MySQL database (made for this test) using this settings:

PHP script: http://devel.wi.net.pl/tunnel/tunnel.php
Database: tunnel
User: tunnel
Pass: tunnel

let me know whether the test was a success.

Other solutions that use the HTTP tunnel by PHP works correctly. This solution is SQLyog (http://www.webyog.com/) tunnel file is available here
http://devel.wi.net.pl/tunnel/SQLyogTunnel.php

Posted: Fri 09 Apr 2010 13:09
by Dimon
Thank you for information. We have reproduced the problem.
Please set in the tunnel.php script the $LOG and $LOG_DEBUG variables to 1, like this:
$LOG = 1;
$LOG_DEBUG = 1;
After trying to connect to a database log files will be generated. Please, send them to me.

Posted: Sun 11 Apr 2010 17:25
by allpower
Hi!
Same problem here too.

When I try to connect via tunnel It throws error message saying
"Can't connect mysql server on localhost ......."

also with Navicat I can connect http tunnel without any problem.

httptunnel_server.log
11.04.2010 19:18:18 - Connected to remote localhost: 3306
11.04.2010 19:18:18 - Waiting for client...

any solution?

Posted: Sun 11 Apr 2010 18:00
by Thomas
Hi,

I get the same error message:

"Can't connect to MySQL server on 'localhost' (10061)
Socket error on read. WSAGetLastError return 10060($274C)."

Content of log file:

11.04.2010 19:56:59 - Connected to remote localhost: 3306
11.04.2010 19:56:59 - Waiting for client...

No problem via http tunnel with Navicat.

Hope you can help.

Posted: Mon 12 Apr 2010 07:06
by dataquest
Hi,
here is a content of my log file:

12.04.2010 08:20:29 - Connected to remote devel.wi.net.pl: 3306
12.04.2010 08:20:29 - Waiting for client...

Posted: Mon 12 Apr 2010 07:18
by Dimon
Please find in tunnel.php all inclusions of the MSG_WAITALL const and change them to 0.

Posted: Mon 12 Apr 2010 07:37
by dataquest
I replaced all 'MSG_WAITALL' to '0' - but still no success.

I found 2 entries in php file:

1.
"$read = socket_recv($socket, $readBuffer, $count, MSG_WAITALL);"
changed to:
"$read = socket_recv($socket, $readBuffer, $count, 0);"

2.
"$readCount = socket_recv($rmsock, $buffer, $MaxReadCount, MSG_WAITALL);"
changed to:
"$readCount = socket_recv($rmsock, $buffer, $MaxReadCount, 0);"

Posted: Mon 12 Apr 2010 08:18
by allpower
same result here no success.
I replaced all 'MSG_WAITALL' to '0' - but still no success.

I found 2 entries in php file:

1.
"$read = socket_recv($socket, $readBuffer, $count, MSG_WAITALL);"
changed to:
"$read = socket_recv($socket, $readBuffer, $count, 0);"

2.
"$readCount = socket_recv($rmsock, $buffer, $MaxReadCount, MSG_WAITALL);"
changed to:
"$readCount = socket_recv($rmsock, $buffer, $MaxReadCount, 0);"

Posted: Tue 13 Apr 2010 12:49
by Dimon
Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.