You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create an SQS queue using Moto (AWS local mock service) in C#, but the queue creation fails (Even same for List oberations). The CreateQueueAsync method always returns null or an error, even though I am using the correct endpoint for the Moto server.
I have started the Moto server using Docker (or other methods) at http://127.0.0.1:5000.
I created an AmazonSQSClient in C# to point to the Moto server:
var sqsClient = new AmazonSQSClient(new AnonymousAWSCredentials(),
new AmazonSQSConfig
{
ServiceURL = "http://127.0.0.1:5000" // Moto server URL
});
I called the CreateQueueAsync method to create a new SQS queue:
public async Task Set_AWS_SQS_QUEUES_IN_MOTO()
{
// Create an SQS client connected to the local moto server
var sqsClient = new AmazonSQSClient(new AnonymousAWSCredentials(),
new AmazonSQSConfig
{
// Use the local Moto server URL
ServiceURL = "http://127.0.0.1:5000",
});
// Create the queue and get the response
var createQueueResponse = await CreateQueueAsync(sqsClient);
}
private static async Task<CreateQueueResponse?> CreateQueueAsync(AmazonSQSClient sqsClient)
{
try
{
// Define the queue parameters
var createQueueRequest = new CreateQueueRequest
{
QueueName = "MyQueue"
};
var createQueueResponse = await sqsClient.CreateQueueAsync(createQueueRequest);
// Return the response if the queue creation is successful
return createQueueResponse;
}
catch (AmazonSQSException sqsEx)
{
// Specific exception handling for Amazon SQS errors
Console.WriteLine($"SQS error occurred: {sqsEx.Message}");
Console.WriteLine($"Error Code: {sqsEx.ErrorCode}");
Console.WriteLine($"Error Type: {sqsEx.ErrorType}");
Console.WriteLine($"Request ID: {sqsEx.RequestId}");
}
catch (Exception ex)
{
// Handle any other general exceptions
Console.WriteLine($"An unexpected error occurred: {ex.Message}");
Console.WriteLine($"Stack Trace: {ex.StackTrace}");
}
// Return null if there was an error
return null;
}
The queue creation fails and returns null.
Additionally, I get this output
2024-11-14 09:35:44 - POST / HTTP/1.1 200 OK
2024-11-14 09:36:10 - POST / HTTP/1.1 200 OK
The text was updated successfully, but these errors were encountered:
maheshtirumerla
changed the title
SQS Queue Creation/ List operation are failing
SQS Queue Creation/ List operations are failing
Nov 14, 2024
Hi @maheshtirumerla, what error does the AWS SDK return? In your example, I would expect to see some output from Console.WriteLine($"SQS error occurred: {sqsEx.Message}"); if there was an error.
How do you start the MotoServer, using which command?
FWIW, I've added this sample as a test case to our CI system, and that seems to pass - see #8323
I am trying to create an SQS queue using Moto (AWS local mock service) in C#, but the queue creation fails (Even same for List oberations). The CreateQueueAsync method always returns null or an error, even though I am using the correct endpoint for the Moto server.
I have started the Moto server using Docker (or other methods) at http://127.0.0.1:5000.
I created an AmazonSQSClient in C# to point to the Moto server:
I called the CreateQueueAsync method to create a new SQS queue:
The queue creation fails and returns null.
Additionally, I get this output
2024-11-14 09:35:44 - POST / HTTP/1.1 200 OK
2024-11-14 09:36:10 - POST / HTTP/1.1 200 OK
The text was updated successfully, but these errors were encountered: