Page 1 of 1

UniDAC + MySQL - Net packets out of order

Posted: Wed 11 Jul 2012 20:17
by miguelenguica
Hi. I'm experiencing odd behavior when using UniDAC 4.14 under Delphi XE and MySQL provider. I'm creating the UniConnection programmatically with:

Code: Select all

    core_knowledge_db:= TUniConnection.Create(nil);
    core_knowledge_db.Database:= knowledge_db_name;
    core_knowledge_db.LoginPrompt:= False;
    core_knowledge_db.ProviderName:= 'MySQL';
    core_knowledge_db.Server:= server_knowledge;
    core_knowledge_db.Username:= username_knowledge;
    core_knowledge_db.Password:= password_knowledge;
    core_knowledge_db.SpecificOptions.Values['Direct']:= 'true';//Direct Mode
    //events
    core_knowledge_db.OnError:= EventHandler.OnConnectionError;
    core_knowledge_db.OnConnectionLost:= EventHandler.OnConnectionLost;
    try
      core_knowledge_db.Connect;
 (..)
The connection works ok and all goes well when I insert data in the main thread. The problem appears when I try to insert data into any table using a separate thread. Then I start getting messages like:

Code: Select all

ReceiveHeader: Net packets out of order: received[252], expected[1]'.
This does not happen when I use SQLite as provider. I have MySQL 5.5.11 installed. Any solution?

Re: UniDAC + MySQL - Net packets out of order

Posted: Thu 12 Jul 2012 13:51
by AndreyZ
Hello,

The only restriction of working in a multi-threaded application is that you must have connection in each thread. You cannot use one connection in several threads. Please check that you have connection (the TUniConnection component) in each thread.

Re: UniDAC + MySQL - Net packets out of order

Posted: Thu 12 Jul 2012 14:36
by miguelenguica
@AndreyZ

That was it. I was not aware of that restriction. Thank you.

If I don't enable the Direct Mode into the SpecificOptions it doesn't work even if the TUniConnection is different is this suppose to be this way? Any other specify option to be careful with in a multi-threaded application?

Re: UniDAC + MySQL - Net packets out of order

Posted: Fri 13 Jul 2012 10:24
by AndreyZ
If you don't use the direct mode, UniDAC uses the libmysql.dll MySQL client library. If libmysql.dll that you are using is not thread-safe, you can encounter different problems when using it in threads. To avoid such problem, we recommend you to use the direct mode. In this mode there is the only restriction of working in a multi-threaded application I mentioned in my previous post.