-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client.Timeout exceeded while awaiting headers #24
Comments
I have the same problem |
I think you will find this is the same issue as #17 and #20 From the go docs:
Therefore whilst you are getting an I think if you try this branch you will get TLS timeout errors as expected. Unfortunately, You will still need to handle the retry logic yourself until apple fixes at their end. |
It may be that you are doing nothing wrong and Apple has patched the error at their end. I just tried now with the same code and i wasn't able to reproduce so hopefully they have fixed it. We pushed back a change to master which has better timeout support. It has timeouts for both the TLS Connection and a standard Timeout, and both of these are configurable. Please try master and let me know if the problem still persists, otherwise i'll close this issue. Thanks |
i have updated the code from master branch and recompile my application, after runing for a period of time, unfortunately, the problem still persists: |
@deamonwatcher what timeout value are you using. Are you using the default timeout or have you got a smaller timeout? |
I use the default timeout,I think it's long enough |
And can you just confirm that |
apns_demo.txt
|
Thanks for the extra info. I am going to try and reproduce this. |
|
@nathany thanks for your reminder. besides, I attach the right trace infomation of a successful send notification: |
It will occur if message was sended after connection had been idle for a long time( 30-60 minutes). |
Hey @deamonwatcher Thanks again for your example code. I have been able to reproduce this The error appears to be happening because you are flooding the HttpClient with more requests than it can send in a reasonable time to APNS. The underlying go HttpClient starts the Timeout timer when you call A couple of ways you could fix;
Hope this makes sense, I will be adding more to the docs to explain this. Please let me know how you get on as i'm keen to see if this resolves the issue. @piouswolf I can't seem to trigger this idle connection scenario. Have tried multiple times with 1m, 15m, 30m, 45m and 1hr and the go HttpClient will always transparently reconnect. I think what may happen in this case (if you have seen this) is APNS is sending a GOAWAY http2 frame. |
@sideshow we still have this problem now, any update on this issue? we are using the latest master code. |
@piouswolf thanks for the info. |
This patch in Go 1.7 rc6 (and x/net/http2) may be related. golang/go@7a62274 |
I have the same problem too. PS:
|
@nange What version of Go are you running? ( |
@nathany like @piouswolf says: |
The problem is related to the Provider setting IdleTimeOut for idle TCP connections. You'll have to send blank data every minute in order to keep it open, or contact your server provider to change the IdleTimeout of your server. |
@sideshow ,first, i ‘m sorry for not reply to you for such a long time, i'm a little busy a short time ago.
Now, the numbers of timeout error is much less than before, but it still have a fatal problem: sending speed. This is unacceptable to my business, and i don't have a good way to solve this problem. My server environment: |
@deamonwatcher this seems like a better channel/goroutine setup. |
I just faced this problem with 3 workers on recent master. But 2 hours later when I try to send another message, everything was fine |
@melkus some logs would be good. Thanks |
Sorry for delay, but we are developing and were playing with different apple certs dev/prod/voip. Push service was started at 2016/11/21 17:24:27 Next messages arrived at 07:05:04 and again some of them were successfully sent, some not. Interesting errors/warnings: Yes, "connection timed out" happened at 07:16 only. It is the first entry of this error in logs. http2 logs, B8CA0FC17F615B0B009A4F2633B7A7DB2F745B748C22EDEDF1A96 token failed: 2016/11/22 07:00:30 http2: Transport encoding header ":authority" = "api.push.apple.com" My logs: |
apns.TLSDialTimeout = 40 * time.Second |
i have the same problem. When i get this error, i recreate Client. Mostly works. |
@deamonwatcher hi, i also have the same problem. the following is my configuration: |
I've the same issue as been filed here a couple of times. I got these kind of errors after my application is running for like maybe a couple of minutes with lots of idle time:
Even though I have an own retry mechanism it fails on every Push after the first timeout. Seems like it does not recover. I also tried to renew the http client in case of a timeout but that doesn't seem to work. I guess because under the hood it still uses the same connection pool. After using the latest update: with a Timeout of 60 seconds it seems to work, but that means sometimes a push-send hangs for one minute to get it out of the door. Isn't there another solution to this? Is this a problem in the http2 implementation in Go or is this an Apple problem? |
I use My solution:
|
@whynotyes seems a nice way, expecting for more details... |
@whynotyes set up a server(located in Hongkong) to act as a proxy server, reduce network delay?We don‘t use the AWS server。 |
@sideshow In my case, this issue is caused by the inactive connection between apns2 and APNS server. The KeepAlive solution works for me. I also added the IdleTimeout. Which will close the connection after a mount of idle time. |
For anyone who face the same problem in China, I made a pull request #129 to add http proxy support for apns2. |
@zhaoxy2850 I got this problem one year ago. i did two things: first, add a http proxy on push machine, second write a restart script, restart the push process when it blocked. |
Thanks, I'm using a http proxy too : ) |
thanks,i will try it
On 03/13/2019 22:39, 川宇 wrote:
For anyone who face the same problem in China, I made a pull request #129 to add http proxy support for apns2.
: )
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
thanks your method solved my problem |
Is there anyway to reset the connection if this "Client.Timeout" error appeared ? |
@bradhowes how do you go about recreating the apns connection? If I don't call |
Hey guys, Our team find a work solution for this problem, the key point is:
The client bucket solution like this: |
in my program, i made 1000 goroutines for concurrency send msg to apple; when i check my log, i find a lot of error returns when i call client.Push, the error is "net/http: request canceled (Client.Timeout exceeded while awaiting headers)"; the timeout setting of the client is 10s:client.HTTPClient.Timeout = time.Duration(10) * time.Second;
i have no idea why this happened, is the timeout setting too short?
The text was updated successfully, but these errors were encountered: