Hi,
I’m using the Go SDK to get a list of devices but the connection to the discovery server just hangs ‘forever’.
I also tried the Python SDK, but after 10 seconds I get a connection failure. (see below)
It does not seem to be a firewall/connectivity issue because running curl(1) returns a response.
$ curl -vv discovery.thethings.network:1900
* Rebuilt URL to: discovery.thethings.network:1900/
* Trying 52.178.215.58...
* Connected to discovery.thethings.network (52.178.215.58) port 1900 (#0)
> GET / HTTP/1.1
> Host: discovery.thethings.network:1900
> User-Agent: curl/7.47.0
> Accept: */*
>
* Connection #0 to host discovery.thethings.network left intact
Below is the Python and Go code I’m testing with.
If anyone can help me diagnose the problem I’d appreciate it. I suspect a gRPC configuration error, but I’m not sure where to start looking and I can’t see anything obvious in /var/log
Thank you.
The following Python code returns a gRPC error - StatusCode.UNAVAILABLE,
$ python
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> from ttn import MQTTClient as mqtt_client
>>> my_client = mqtt_client("wfs-sodaq-app","ttn-account-v2.7y48***************")
>>> my_client.connect()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ian/env/test/lib/python3.5/site-packages/ttn/ttnmqtt.py", line 110, in connect
res = stub.GetByAppID(req)
File "/home/ian/env/test/lib/python3.5/site-packages/grpc/_channel.py", line 484, in __call__
return _end_unary_response_blocking(state, call, False, deadline)
File "/home/ian/env/test/lib/python3.5/site-packages/grpc/_channel.py", line 434, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNAVAILABLE, Connect Failed)>
>>>
For the Go code I get,
$ go run main.go
DEBUG wfs-sodaq-app ttn-account-v2.7y48Aq*************************
DEBUG here
DEBUG ttn-sdk: Connecting to discovery... Address=discovery.thethings.network:1900
and it never returns or raises any errors.
main.go - A copy of the first example in the SDK docs.
package main
import (
"fmt"
"os"
ttnsdk "github.com/TheThingsNetwork/go-app-sdk"
ttnlog "github.com/TheThingsNetwork/go-utils/log"
"github.com/TheThingsNetwork/go-utils/log/apex"
)
const (
sdkClientName = "my-amazing-app"
)
func main() {
log := apex.Stdout() // We use a cli logger at Stdout
log.MustParseLevel("debug")
ttnlog.Set(log) // Set the logger as default for TTN
// We get the application ID and application access key from the environment
appID := os.Getenv("TTN_APP_ID")
appAccessKey := os.Getenv("TTN_APP_ACCESS_KEY")
log.Debug(appID + " " + appAccessKey)
// Create a new SDK configuration for the public community network
config := ttnsdk.NewCommunityConfig(sdkClientName)
config.ClientVersion = "2.0.5" // The version of the application
// Create a new SDK client for the application
client := config.NewClient(appID, appAccessKey)
// Make sure the client is closed before the function returns
// In your application, you should call this before the application shuts down
defer client.Close()
log.Debug("here")
// Manage devices for the application.
devices, err := client.ManageDevices()
if err != nil {
log.WithError(err).Fatal("my-amazing-app: could not get device manager")
}
log.Debug("here2")
// List the first 10 devices
deviceList, err := devices.List(10, 0)
if err != nil {
log.WithError(err).Fatal("my-amazing-app: could not get devices")
}
log.Info("my-amazing-app: found devices")
for _, device := range deviceList {
fmt.Printf("- %s", device.DevID)
}
}