Skip to content
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

dial tcp: xxxxxx read udp xxxxxx:38055->xxxxxx:53: i/o timeout #140

Open
sshallow opened this issue Jul 8, 2019 · 1 comment
Open

dial tcp: xxxxxx read udp xxxxxx:38055->xxxxxx:53: i/o timeout #140

sshallow opened this issue Jul 8, 2019 · 1 comment

Comments

@sshallow
Copy link

sshallow commented Jul 8, 2019

When I call apns2, it sometimes returns a timeout and the process will shut down.
I am using go version go1.12.5 darwin/amd64
I have seen #24 and #21, I understand that they have solved it,but there will still be problems.
My code

func ApplePushNotificationService(deviceToken string, parameters string) {
	fmt.Println("开始推送", deviceToken, parameters)
	cert, err := certificate.FromP12File("./hookupAPNS.p12", "******") //filename 为服务器上的p12文件地址
	if err != nil {
		log.Fatal("Cert Error:", err)
	}
	notification := &apns2.Notification{}
	notification.DeviceToken = deviceToken
	notification.Topic = "com.preferme.hookup"
	payload := payload.NewPayload().Alert(parameters).AlertBody(parameters).Badge(1).Sound("sound.wav").Custom("key", "val")
	notification.Payload = payload
	client := apns2.NewClient(cert).Production()
	res, err := client.Push(notification)
	if err != nil {
		log.Fatal("push Error:", err)
	}
	fmt.Printf("%v %v %v\n", res.StatusCode, res.ApnsID, res.Reason)
}

error log

push Error:Post https://api.development.push.apple.com/3/device/4dc8efa9c46b0206c2e6e0dda6a1314c457704f897747ae1f7dffe4ef31a443b: dial tcp: lookup api.development.push.apple.com on 10.143.22.116:53: read udp 10.116.213.185:38055->10.143.22.116:53: i/o timeout
@sideshow
Copy link
Owner

sideshow commented Nov 30, 2019

Hi @sshallow This looks like you could be using a proxy server and the problem is related to either that or a flakey internet connection rather than apns2. By default apns2.HTTPClientTimeout is set to 60 seconds. You could either try making that value larger (to reduce the timeout errors), or using a server with a better connection in the US. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants