UniDAC + MySQL - Net packets out of order

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
miguelenguica
Posts: 18
Joined: Mon 11 Apr 2011 15:28

UniDAC + MySQL - Net packets out of order

Post by miguelenguica » Wed 11 Jul 2012 20:17

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?

AndreyZ

Re: UniDAC + MySQL - Net packets out of order

Post by AndreyZ » Thu 12 Jul 2012 13:51

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.

miguelenguica
Posts: 18
Joined: Mon 11 Apr 2011 15:28

Re: UniDAC + MySQL - Net packets out of order

Post by miguelenguica » Thu 12 Jul 2012 14:36

@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?

AndreyZ

Re: UniDAC + MySQL - Net packets out of order

Post by AndreyZ » Fri 13 Jul 2012 10:24

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.

Post Reply