I developing a binding (Shelly), which uses a HTTP REST API to retrieve device information for various purpose and control the device. Works fine in general. However, multiple users see http Timeouts in the log, which then cause a command to fail or the thing rapidly changing between ONLINE and OFFLINE state (timeout results in setting thing to OFFLINE state). One user even has this problem persistant, even can’t add discover Shelly things, because the call for initially retrieving device settings fails.
I use the OH build-in HttpUtil class
httpResponse = HttpUtil.executeUrl(HttpMethod.GET, url, headers, null, "", SHELLY_API_TIMEOUT_MS);
The timeout is set to 6sec, even increasing it to 30sec doesn’t help.
I found this post:
seems to be the same symptom, but but this one is related to a https related problem, whereas I’m using generic http, so no certificates (should be) are involved. The device also doesn’t support https.
I my setup I see those timeouts very rarely (implemented a channel to count them), but other users are reporting relevant issues. I’m using OH 2.4 on a RPI, other users 2.5. The problem is reported for different device types and firmware versions. WiFi signal strength is verified and good. Manuel execution of the URLs in a browser or with curl don’t show these problems. Also the Shelly mobile and Web Apps don’t report errors.
The binding has 3 use cases for the http calls
- Retrieve device information on discovery (as part of the createResult() call)
- Executing channel commands (handleCommand() of the thing handler)
- Status updates within a thread scheduled by scheduler.scheduleWithFixedDelay()
I though already about a problem around synchronization or thread context, but was not able to proof this. However, sometimes I see in the debugger that a call to HttpUtil.executeUrl() takes longer that just a sec, what I wouldn’t expect on a local WLAN.
@martinvw Maybe you have an idea?
Next step to find a work around could be to replace HttpUtil by generic JDK calls (I had this at the beginning, but then changed to HttpUtil).