huysentruitw / SapNwRfc

SAP NetWeaver RFC library for .NET 5, .NET Core and .NET Framework
MIT License
148 stars 43 forks source link

Pool connection blocked ? #43

Closed lucas-garrido closed 2 years ago

lucas-garrido commented 3 years ago

Hello, i'm facing an issue that im not able to resolve by myself.

My code looks like something like that :

// EditContactFunction
_sapConnection.InvokeFunction<ContactCreateOutput>("ZSD_CUSTOMER_MAINTAIN_ALL", params)
var commitResult1 = _sapConnection.InvokeFunction<CommitTransactionResult>("BAPI_TRANSACTION_COMMIT", new { WAIT = "X" });
_sapConnection.InvokeFunction<AddressCreateOutput>("BAPI_ADDRESSCONTPART_CHANGE", params2)
var commitResult2 = _sapConnection.InvokeFunction<CommitTransactionResult>("BAPI_TRANSACTION_COMMIT", new { WAIT = "X" });

I dont understand why but :

It looks like i have to wait X seconds between every run of the edit function if i want the second invoke to works

I tried to add

 _sapConnection.Dispose();

after every BAPI_TRANSACTION_COMMIT and the behaviour changed a little bit : Both invoke worked fine but i can run my edit function only 5 time (which is my poolsize) after that the invoke is blocked and never return

any idea ?

huysentruitw commented 3 years ago

Hi Lucas,

can you be more specific what you mean by "first invoke" and "second invoke". Seems like you're talking about 2 invokes, while your example contains 4 invokes.

From where do you get the _sapConnection? If you dispose the _sapConnection, how do you recreate it for the BAPI_ADDRESSCONTPART_CHANGE call?

lucas-garrido commented 3 years ago

Hi ! Sorry i was talking about ZSD_CUSTOMER_MAINTAIN_ALL + COMMIT as first invoke "block" and BAPI_ADDRESSCONTPART_CHANGE + COMMIT as second one

this is how i get the sapConnection :

startup.cs image image

BapiService.cs image

Mutation.cs image

If you dispose the _sapConnection, how do you recreate it for the BAPI_ADDRESSCONTPART_CHANGE call?

Well i dont know 😁 thought it was going to acquire new connection from the pool automatically. Anyway i only did it for testing i'm not supposed dispose after each call, right ?

lucas-garrido commented 3 years ago

i have tried to change the BAPI_ADDRESSCONTPART_CHANGE by another random BAPI and it works every time, so i guess the problem is coming when combining this two BAPI... maybe a lock issue ? as i said adding dispose() after first commit resolve the problem but its opening new connections image