How to publish message to SNS in Windows Forms (NET6) app?

0

I have created SNS topic FIFO, my c# app queried all topics and see all of them including mine.

Then I'd like to publish message to the topic. I use this code, it works in NET6 app but it hangs on PublishAsync when I use it in Windows Forms (NET6)

 public async Task<string> PublishMessageHandler103(string messageText, string msgGroup)
 {
     try
     {
         string topicArn = topicarn;
         var awsCredentials = new Amazon.Runtime.BasicAWSCredentials(accKey, secKey);
         var client = new Amazon.SimpleNotificationService.AmazonSimpleNotificationSer‌​viceClient(awsCreden‌​tials, regionEndpoint);
         var request = new PublishRequest
         {
             TopicArn = topicArn,
             Message = messageText,
             MessageGroupId = msgGroup
         };
         var response = await client.PublishAsync(request);// <----Hangs
         Console.WriteLine($"Successfully published message ID: {response.MessageId}");
         return $"Message Published: {msg}";
     }
     catch (Exception ex)
     {
         Console.WriteLine("\n\n{0}", ex.Message);
     }
     return "Hmmm";
 }
Oleg
質問済み 8ヶ月前246ビュー
1回答
-1

Hello.

The following documentation contains sample code for sending messages to Amazon SNS.
If I use this one, can I send a message successfully?
https://docs.aws.amazon.com/sns/latest/dg/example_sns_Publish_section.html

profile picture
エキスパート
回答済み 8ヶ月前
profile pictureAWS
エキスパート
レビュー済み 8ヶ月前
  • I have updated my question. Please look. The code works in NET 6 app but it hangs in Windows Forms (NET6) app

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ