Hello everyone.
I got in trouble when I try to use go-app-sdk to create a ttn client while the ttn is in my local desktop.
I follow the steps of GoLang Quick Start, in addition, I set the discovery address to my own. like this
config := ttnsdk.NewCommunityConfig(sdkClientName)
config.ClientVersion = "2.0.5"
config.DiscoveryServerAddress = "discovery-serv:1900"
config.TLSConfig = new(tls.Config)
certBytes, err := ioutil.ReadFile(certPath)
if err != nil {
log.WithError(err).Fatal("my-amazing-app: could not read CA certificate file")
}
config.TLSConfig.RootCAs = x509.NewCertPool()
if ok := config.TLSConfig.RootCAs.AppendCertsFromPEM(certBytes); !ok {
log.Fatal("my-amazing-app: could not read CA certificates")
}
client := config.NewClient(appID, appAccessKey)
defer client.Close()
I can get a DeviceManger
object, but when I try to List
my devices of my app, it crashed with a Token not found or expired
error. And it turns out that the error happend when it run to ExchangeAppKeyForToken()
of go-account-lib
, it makes a post request to /api/v2/applications/token
.
I thought it might be that I don’t have an account server ID, and I requested one, but I was wrong.
Is local ttn is not allowed or anything else ?