Connecting via HTTP tunnel by PHP - libmysql.dll error

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
dataquest
Posts: 10
Joined: Tue 06 Apr 2010 13:38

Connecting via HTTP tunnel by PHP - libmysql.dll error

Post by dataquest » Tue 06 Apr 2010 13:55

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?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 07 Apr 2010 08:42

To solve this problem try to use the Direct mode to connect to MySQL database. For this the TMyConnection.Options.Direct property to True.

dataquest
Posts: 10
Joined: Tue 06 Apr 2010 13:38

Post by dataquest » Wed 07 Apr 2010 10:17

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)."

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 07 Apr 2010 11:45

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.

dataquest
Posts: 10
Joined: Tue 06 Apr 2010 13:38

Post by dataquest » Thu 08 Apr 2010 09:24

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?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 08 Apr 2010 14:27

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.

dataquest
Posts: 10
Joined: Tue 06 Apr 2010 13:38

Post by dataquest » Fri 09 Apr 2010 10:22

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

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 09 Apr 2010 13:09

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.

allpower
Posts: 2
Joined: Sun 11 Apr 2010 17:13

Post by allpower » Sun 11 Apr 2010 17:25

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?

Thomas
Posts: 2
Joined: Sun 11 Apr 2010 17:51

Post by Thomas » Sun 11 Apr 2010 18:00

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.

dataquest
Posts: 10
Joined: Tue 06 Apr 2010 13:38

Post by dataquest » Mon 12 Apr 2010 07:06

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...

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 12 Apr 2010 07:18

Please find in tunnel.php all inclusions of the MSG_WAITALL const and change them to 0.

dataquest
Posts: 10
Joined: Tue 06 Apr 2010 13:38

Post by dataquest » Mon 12 Apr 2010 07:37

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);"

allpower
Posts: 2
Joined: Sun 11 Apr 2010 17:13

Post by allpower » Mon 12 Apr 2010 08:18

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);"

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 13 Apr 2010 12:49

Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.

Post Reply