When I try to run the Smartthings CLI in Termux (Android Linux shell) Iβm getting the following error:
~/ST3 $ ./smartthings devices --token=...
Error: getaddrinfo EAI_AGAIN api.smartthings.com
Code: EAI_AGAIN
Name resolver works:
~/ST3 $ nslookup api.smartthings.com
Server: 62.109.121.17
Address: 62.109.121.17#53
Non-authoritative answer:
Name: api.smartthings.com
Address: 54.77.208.161
Name: api.smartthings.com
Address: 46.137.152.66
Name: api.smartthings.com
Address: 54.72.46.217
Name: api.smartthings.com
Address: 34.252.8.126
Name: api.smartthings.com
Address: 34.250.148.12
Name: api.smartthings.com
Address: 52.209.180.133
Name: api.smartthings.com
Address: 54.194.210.61
Name: api.smartthings.com
Address: 108.128.33.190
Debugging on:
[2024-08-23T20:24:12.500] [DEBUG] rest-client - making axios request: {"url":"https://api.smartthings.com/devices","method":"get","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/vnd.smartthings+json;v=20170916","User-Agent":"@smartthings/cli/1.9.0 linux-arm node-v18.5.0","Accept-Language":"en-US","Authorization":"Bearer 3a3b0e61-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},"params":{"capabilitiesMode":"and"}}
Error: getaddrinfo EAI_AGAIN api.smartthings.com
at Function.from (/snapshot/smartthings-cli/node_modules/axios/lib/core/AxiosError.js:86:14)
at RedirectableRequest.handleRequestError (/snapshot/smartthings-cli/node_modules/axios/lib/adapters/http.js:391:25)
at RedirectableRequest.emit (node:events:537:28)
at ClientRequest.<anonymous> (/snapshot/smartthings-cli/node_modules/follow-redirects/index.js:38:24)
at ClientRequest.emit (node:events:537:28)
at TLSSocket.socketErrorListener (node:_http_client:465:9)
at TLSSocket.emit (node:events:537:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
This is a test if the node module Axios works:
~/ST3 $ cat test.js
const axios = require('axios');
// GET-Anfrage an eine API
axios.get('https://api.smartthings.com/devices/')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
Execution:
~/ST3 $ node test.js
Error: AxiosError: Request failed with status code 401
at settle (/data/data/com.termux/files/home/node_modules/axios/dist/node/axios.cjs:2015:12)
at Unzip.handleStreamEnd (/data/data/com.termux/files/home/node_modules/axios/dist/node/axios.cjs:3131:11)
at Unzip.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1696:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
at Axios.request (/data/data/com.termux/files/home/node_modules/axios/dist/node/axios.cjs:4262:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ERR_BAD_REQUEST',
[...]
response: {
status: 401,
statusText: 'Unauthorized',
headers: Object [AxiosHeaders] {
date: 'Fri, 23 Aug 2024 20:59:19 GMT',
'transfer-encoding': 'chunked',
connection: 'keep-alive',
server: 'openresty',
'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS',
'access-control-allow-headers': 'DNT,Keep-Alive,User-Agent,If-Modified-Since,Cache-Control,Content-Type,Accept,Authorization,X-ST-Client,X-ST-Api-Version,X-ST-Client-AppVersion,X-ST-Client-OS,X-ST-Client-DeviceModel'
},
As you can see it basically works, just not authorized but it can resolve api.smartthings.com.
The same Smartthings CLI executable works on a virtual server but not in Termux. It is statically linked (smartthings-linuxstatic-armv7.tar.gz) so maybe something is missing?