Hi @murusolai , welcome to the Community!
I’m not a .NET expert like @nicholasdgoodman > , but I know a few things about our API that I’d just like to point out / mention…
First, I’m wondering why you are changing some of the default API properties, specifically for:
SdkBufferSize = 8000000,
SocketSendBufferSizeInBytes = 8000000,
SocketReceiveBufferSizeInBytes = 8000000,
ConnectTimeoutInMsecs = 300,
Are you just experimenting with different values to see if they help? Note: 300ms is VERY aggressive for a connection timeout setting (default 3000ms).
Next, in your message handler, you are doing:
Console.WriteLine(folderName + “- Message - " + DateTime.Now.ToString());
string responseMsg = Encoding.ASCII.GetString(message.BinaryAttachment);
Guid guid = Guid.NewGuid();
AmazonS3Utility s3Utility = new AmazonS3Utility();
await s3Utility.UploadFileAsync(responseMsg, string.Format(”{0}_data.json", guid), folderName); // Upload the message to AWS S3
Flow.Ack(message.ADMessageId);
WaitEventWaitHandle.Set();
Now, in C and C# APIs, the thread that runs the “on message” event handler is an API thread, the Context thread, not an application-owned thread. And this is the only thread the API has for performing all other API-related functions (e.g. reading the socket, running timers, etc.). It is very strongly discouraged from doing any significant amount of work in your callback for this reason. And in your case, you are trying to do a blocking send to an S3 cloud service. This can have significant issues on the API, including forcing a disconnect due to keepalive timers expiring due to the Context thread being blocked for too long.
There is more information here: Creating Contexts and here: API Threading
Ideally, your callback will simply take the IMessage to be processed, stick it into some internal processing queue/linked list/ring buffer and return. And you’d have other application-owned threads that are blocking on that data structure, pulling messages out, processing them to S3, and then ACKing and Dispose() ing them when complete.
If the broker is sending you more data than your app can take in, there is always the IFlow.Start() and Stop() methods to temporarily pause message delivery.
Hope that helps!? ??