Adyen / adyen-dotnet-api-library

Adyen API Library for .NET
MIT License
103 stars 115 forks source link

[ECP-9257] System.IO Exception from adyen client #1007

Open JuanOG-Kyo opened 2 months ago

JuanOG-Kyo commented 2 months ago

We have noticed many times in production when the adyen client just randomly throws a 500 exception with Error Type: System.IO Error Message: The response ended prematurely.

Steps to reproduce the behavior: I am not sure as this occurs at random times on random days

Expected behavior A request made using the adyen client should complete the request and on any errors it should throw more meaningful exceptions or a properly structured response.

Context on how we use the client We run our app in a linux environment and we create a new adyen client on every request but we proved the httpclient from the http client factory. The primary message handler is the one produced by adyens createmessagehandler function. Which seems to be to aid with terminal requests.

Screenshot Screenshot_20240411-000102.png

DjoykeAbyah commented 1 month ago

Hi @JuanOG-Kyo!

Creating a new http client for every request is not recommended. You would rather re-use the HttpClient. Perhaps this closed git issue would be of use. They had a similar issue to yours.

Regards,

Djoyke Adyen

JuanOG-Kyo commented 1 month ago

Hi @JuanOG-Kyo!

Creating a new http client for every request is not recommended. You would rather re-use the HttpClient. Perhaps this closed git issue would be of use. They had a similar issue to yours.

Regards,

Djoyke Adyen

@DjoykeAbyah we use the Microsoft recommended way of using the http client factory which will reuse the connections, so i don't see how that would cause the issue.

DjoykeAbyah commented 1 month ago

@JuanOG-Kyo,

My apologies I wasn't aware of that! Then it's indeed very strange that you receive these error messages. I'll need to look into this a bit deeper to see what's going on. Could you maybe provide a code snippet so I can try to recreate the process?

JuanOG-Kyo commented 1 month ago

image image

@DjoykeAbyah This is a sample of the code we use to call TerminalRequestAsynchronousAsync() which seems to have had a couple of these exceptions occur. Note: this doesn't occur that frequently, maybe 5 times out of 3000 requests (Rough estimates).

DjoykeAbyah commented 4 weeks ago

@JuanOG-Kyo

Thank you for providing the snippet! I'll dive into it and get back to you!