Aero Gear .Net clientを使用してプッシュ通知を送信するための呼び出しを待機しています。プッシュへの呼び出しからの戻り値はSystem.Net.HttpStatusCode
です。プッシュが成功した場合の期待されるコードは "Accepted"です。HttpStatusCodeへの待機中の呼び出しに対する中止された要求を解決するには?
しかし、私はSendPushNotificationメソッドの呼び出しを待っていたときにHttpStatusCodeは、このラインでメソッドから返される前に、それは"The request was aborted. The connection was closed unexpectedly"
エラーがスローされます。
System.Net.HttpStatusCode status = await client.Send(unifiedMessage);
私はプッシュまで、コントローラからのコールをマークメソッドを非同期として呼び出し、非同期メソッドの呼び出しがあったところを追加します。
質問:
どのようHttpStatusCodeに待望のコールで中止された要求を解決することができますか?
これはコールの要旨では、プッシュクラスメソッドにコントローラにダウン最初の呼から細流:
コントローラー:
//In Controller Post action that calls SendPushNotification
[HttpPost]
public async Task<ActionResult> Index(Order exec_order)
{
try
{
//Send a push notification with the order details
try
{
MyLogger.FileLogger.Info("Before Push Notification");
System.Net.HttpStatusCode status = await PushsClassLibrary.PushNotification.SendPushNotification(exec_order.Application", "Order Summary");
MyLogger.FileLogger.Info("Push Notification Status: " + status);
}
catch (Exception ex) //request aborted error caught here
{
MyLogger.FileLogger.Error("Push Notification Exception -" + ex.Message);
}
}
プッシュクラス:
//In PushNotification class containing SendPushNotification
public static async Task<System.Net.HttpStatusCode> SendPushNotification(string messageToPush, string serviceName)
{
string[] listUsers = users.ToArray();
unifiedMessage.criteria.alias = listUsers;
System.Net.HttpStatusCode status = await client.Send(unifiedMessage);
return status;
}
あなたのメソッド 'SendPushNotification()'は何の例外も投げないのですか? – Rahul