question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timeout exception

See original GitHub issue

Hello.

Sometimes I have Timeout exception when I send APN to apple server. Below is my exception StackTrace:

System.AggregateException: One or more errors occurred. —> System.TimeoutException: The operation has timed out. at HttpTwo.Http2Client.<Send>d__19.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at HttpTwo.Http2Client.<Send>d__17.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at HttpTwo.Http2Client.<Post>d__15.MoveNext() — End of inner exception stack trace — at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at PushNotificationAPI.Controllers.AppleController.SendNotification(String jwtToken, String deviceToken, String topic, Object payload, Boolean isProduction) at PushNotificationAPI.Controllers.AppleController.PushNotification(String kid, String iss, String topic, String authKey, Boolean isProduction, String deviceToken, Object payload) —> (Inner Exception #0) System.TimeoutException: The operation has timed out. at HttpTwo.Http2Client.<Send>d__19.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at HttpTwo.Http2Client.<Send>d__17.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at HttpTwo.Http2Client.<Post>d__15.MoveNext()<—

My code here:

private AppleResponseModel SendNotification(string jwtToken, string deviceToken, string topic, object payload, bool isProduction)
        {
            var domain = isProduction ? "https://api.push.apple.com:443" : "https://api.development.push.apple.com:443";
            var uri = new Uri($"{domain}/3/device/{deviceToken}");

            var client = new Http2Client(uri);

            var headers = new NameValueCollection
            {
                {"apns-id", Guid.NewGuid().ToString()},
                {"apns-expiration", "0"},
                {"apns-priority", "10"},
                {"apns-topic", topic},
                {"authorization", $"bearer {jwtToken}"}
            };

            var body = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(payload));

            var response = client.Post(uri, headers, body).Result;

            var responseBody = Encoding.ASCII.GetString(response.Body);
            var notificationId = response.Headers["apns-id"];

            return new AppleResponseModel(response.Status, responseBody, notificationId);
        }

Could you please help me what going wrong?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:14

github_iconTop GitHub Comments

1reaction
Neiocommented, Aug 2, 2017

@Jent05 Unfortunately, I doubt that HttpTwo library supports that. When I use it, I use lock to make sure other thread finished using HttpTwo.

1reaction
Neiocommented, Jul 13, 2017

This happened because it is talking to wrong TCP connection somethings. I have some fixes in my fork.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TimeoutException (Java Platform SE 8 ) - Oracle Help Center
Exception thrown when a blocking operation times out. Blocking operations for which a timeout is specified need a means to indicate that the...
Read more >
TimeoutException Class (System) - Microsoft Learn
The exception that is thrown when the time allotted for a process or operation has expired.
Read more >
How to deal with timeout exception in Java? - Stack Overflow
When the exception is caught, I just want the thread to sleep for a while, then try to get the remote resource again....
Read more >
TimeoutException - Android Developers
Exception thrown when a blocking operation times out. Blocking operations for which a timeout is specified need a means to indicate that the...
Read more >
TimeOutException in Selenium - Educative.io
In Selenium, TimeOut exception occurs when a command takes longer than the wait time to avoid the ElementNotVisible Exception.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found