Sometimes it works, but most of the time I get this error:
2020-04-19 20:24:59.221 [ERROR] [pse.smarthome.model.script.Speedtest] - --> speedtest failed. Output:
{"type":"log","timestamp":"2020-04-19T18:24:30Z","message":"Error: [11] Cannot read from socket: Resource temporarily unavailable","level":"error"}
{"type":"result","timestamp":"2020-04-19T18:24:59Z","ping":{"jitter":0.57799999999999996,"latency":6.4829999999999997},"download":{"bandwidth":11032873,"bytes":130671864,"elapsed":12602},"upload":{"bandwidth":26750187,"bytes":383575374,"elapsed":15008},"packetLoss":0,"isp":"xxx","interface":{"internalIp":"xxx","name":"eth0","macAddr":"xxx","isVpn":false,"externalIp":"xxx"},"server":{"id":21509,"name":"i3D.net","location":"Rotterdam","country":"Netherlands","host":"eu.speedtest.i3d.net","port":8080,"ip":"213.163.76.135"},"result":{"id":"a9ff64fd-2e43-4f7d-a340-2920151aa027","url":"https://www.speedtest.net/result/c/a9ff64fd-2e43-4f7d-a340-2920151aa027"}}
I changed your “fairly simple error check” to:
if (speedtestCliOutput.startsWith("{\"type\":") && speedtestCliOutput.endsWith("}}"))