I use github.com/sideshow/apns2 of specified revision in my project to send IOS push notifications. The go 1.7.4 is inside of a docker container and I have compiled the app there and pulled the binary to the host machine. When I run the binary on the host it throws the next error:
Error Message: Post https://api.push.apple.com/3/device/{device_token}: dial tcp: lookup api.push.apple.com on 127.0.1.1:53: read udp 127.0.0.1:33891->127.0.1.1:53: i/o timeout
but running inside of a docker works as expected.
here is a part of code:
import (
"os"
"strings"
apns "github.com/sideshow/apns2"
"github.com/sideshow/apns2/token"
)
var ApnsClient *apns.Client
authKey, err := token.AuthKeyFromBytes([]byte(strings.Replace(os.Getenv("APNS_AUTH_KEY"), "\
", "
", -1)))
if err != nil {
return err
}
Token := &token.Token{
AuthKey: authKey,
KeyID: os.Getenv("APNS_KEY_ID"),
TeamID: os.Getenv("APNS_TEAM_ID"),
}
if os.Getenv("APNS_PRODUCTION") == "1" {
ApnsClient = apns.NewTokenClient(Token).Production()
} else {
ApnsClient = apns.NewTokenClient(Token).Development()
}
notification := &apns.Notification{
Payload: {payload},
Topic: {bundle id},
DeviceToken: {device_token}
}
res, err := ApnsClient.Push(notification)
HTTP status in res is 200
any ideas how to fix this?
Your DNS resolution seems to have been compiled into your go-executable a mad way: 127.0.0.1:33891->127.0.1.1:53
What you see here is a port-binding of docker to your local host-dns server. This will not work on the host, but it does also make no sense having this "route" compiled into the go-executable.
Probably, you are compiling a static connection string into the APP, for the connection to the DNS server, i really cannot guess here.