.Net API (502) Bad Gateway error

Iam using Tamino .net API to insert xml documents to Tamino,while I have one server what creates the xml and inserts created xml to other server that dedicated to run the Tamino db.

The problem: while using API transactions where are some times (after 10 or more minutes of inserting docs to Tamino) Exception rised by TaminoAPI and it sais the remote server returned an error: (502) Bad Gateway.

if I do the same work(insert the xml data to Tamino) without transaction it works ok,the problem is only with transactions.
i think that if the xml files are smaller then the problem happens more frequently.
if I do " Thread.Sleep(15);" to the thread that runs the transaction it works ok.

Why this error happens and what is the right way to solve it if I have to use transactions and i can not use thread sleeping becouse the performance is important to me.