I used Zeoslib 6.6.0-beta with Delphi 7 to write some business logics on server side that must create TZConnection on the fly per client call.But if calling is in loop for a long time, I got error 'Can't connect to MySQL server on 127.0.0.1 (10048)' and MySQL stop working for about 1 minute. I try to simulate the following code which make equivalent situation and the same error. Can anyone help? I used MySQL 5.0.45 and its default settings.
for i:=0 to 6000 do {more likely error for more loop count}
begin
Con := TZConnection.Create(nil);
Q := TZQuery.Create(nil);
try
Con.Database := 'myDB';
Con.User := 'root';
Con.Password := 'mypassword';
Con.HostName := '127.0.0.1';
Con.Protocol := 'mysql-5';
Q.Connection := Con;
Q.Close;
Q.SQL.Text := 'select item_id from items';
Q.Open;
finally
Q.Free;
Con.Free;
end;
end;
Jaras
Can't connect to MySQL if open/close TZConnection in loop.
Moderators: gto, cipto_kh, EgonHugeist
Well, I think it's a very expected behavior.
Mostly databases have a protection for many connections from the same IP in a little space of time. You should connect once, maybe reconnect a few times later, but never do this loop bases connect/disconnect. Even because you're not calling Con.Disconnect, which should be more readable
Try to increase the max-connections in my.ini configuration file.
Mostly databases have a protection for many connections from the same IP in a little space of time. You should connect once, maybe reconnect a few times later, but never do this loop bases connect/disconnect. Even because you're not calling Con.Disconnect, which should be more readable
Try to increase the max-connections in my.ini configuration file.
The max value for max_connections is 16384.
If your application runs on Windows XP or Vista there is a limit of the used (client) ports.
You can check this by write netstat to cmd. Then you will see how many connections are open.
On win XP there is a limit of 4000 concurrently opend ports. And every port will not closed until 240 seconds without activity.
You can incrase this by change two settings in the windows registry:
http://technet.microsoft.com/en-us/libr ... 97382.aspx
I hope this can solve your problem.
If your application runs on Windows XP or Vista there is a limit of the used (client) ports.
You can check this by write netstat to cmd. Then you will see how many connections are open.
On win XP there is a limit of 4000 concurrently opend ports. And every port will not closed until 240 seconds without activity.
You can incrase this by change two settings in the windows registry:
http://technet.microsoft.com/en-us/libr ... 97382.aspx
I hope this can solve your problem.