Comm.makeWebRequest starts failing until a reboot of 935

I have a CIQ app that I use as my everyday watch face that calls makeWebRequest about once every 30 seconds. It's doing this to get status update of my house (lights that are on, garage door opened or closed, current weather at the house). Until a couple weeks ago, this would run without problem for days on end. Recently it started failing after anywhere from 12 to 48 hours, getting no response back from makeWebRequest. Even if I exit the app back to the standard watch face and then restart my app, the makeWebRequest still doesn't succeed. Even if I plug it in to the computer and upload a new version of the app. As soon as I reboot (power down and back up) the watch, it starts working flawlessly again.

The app continues to run flawlessly other than not getting responses from makeWebRequest so it isn't that the app is crashing. No error in CIQ_LOG.TXT.

Given that restarting the app without rebooting the watch doesn't fix the problem, I'm guessing it is something in the system code causing this.

It doesn't seem like a problem with the phone connection since everything else with the BT connections seems to work.
  • My first thought is that something maybe be getting "congested" along the way. Before you do a makeWebRequest, are you making sure you heard back on the last one? As you are doing the request every 30 seconds, there is a chance it could take longer than that to time out based on the conditions of the connection, etc.

    If you change the time from 30 seconds to say every 1-2 minutes, does it still happen? Also, I'd check phoneConnected each time before doing the makeWebRequest, and skip the request if it's false.

    In general, have you considered using a background process for this? Have it make the request every 5 minutes, even if the app isn't running, and that way, the app has got data when it starts and doesn't need to wait for the comm.
  • I do check for phone connection immediately before sending the request. I also avoid making the request if there is a request pending, although I do have a time out where I will assume the response has just failed. Looking at my code, it's a bit convoluted so I need to go through it. But it often seems to happen at night when the phone and watch are sitting right next to each other.

    I want quick response as I want status info from the home automation. When I turn the lights on from my watch, I want a quick response as to if it worked. Similarly, my watch face turns red and the watch vibrates when the garage door is opened. Don't want to wait 5 minutes for this.

    But two things of note. This was working flawlessly with no changes to my app connected via the same iPhone. Regardless of what my app does, system resources should be reset for the next app that starts. I shouldn't have to reboot the device to reset it.

    Also, if it were a congestion thing, I'd expect the system to timeout at some point. But several hours later, it still won't work until I reboot the device.
  • Former Member
    Former Member
    Do you know if a device firmware or Garmin Connect Mobile corresponded with the change in behavior?

    Could you try replacing your web request with something more generic to see if it still reproduces this issue? We'd probably want to reproduce something like this in house to investigate if possible.
  • Thanks Brian. I've added some additional debug code, logging time stamps of every request and response as well as BT connection status to make sure requests/response are properly paired in order to be confident the logic is correct (per Jim's suggestion). I often don't realize the calls start failing until several hours later, but I already do show when the last successful response occurred. This combination should help me figure out the sequence just before the failure. Unfortunately this can take days to have happen.

    I don't have logs that show exactly when it started so can't say if it coincided with a watch or GCM update. Almost certainly less than 6 weeks and more than 2.

    As I said, it doesn't get fixed for my app until I reboot the watch but I haven't tried running another app making a request to another web page. I just built and installed the WebRequest widget from the samples and will see if that succeeds next time my watch fails. Will give me a bit of additional information.
  • Former Member
    Former Member
    I have noticed the same problem and will try to give the details of my issue. About a week ago, I noticed that my CIQ watch face which gets weather via webrequest was not updating. From the weather website, I can tell that the request is getting to the website but something is failing to get back to the watch. While troubleshooting, I found that two other apps were also failing in the same manner. I rebooted the watch and all three CIQ apps started working. They worked for about 24 hours and then failed again. This pattern is continuing to repeat. All three programs had been running successfully for more than 4 months and I haven't updated them recently so I'm thinking something changed in GCM or in the watch firmware. I'm using a vivoactive HR (SW version 4.40) paired with an iPhone running GCM (Version 4.7.0.14). I did recompile my watch face with CIQ SDK 2.4.6 but the behavior remains the same.
  • Randy, glad to see I'm not alone here.

    After adding the above debug code, it failed pretty quick but I didn't notice it for a couple hours as I was out on a long run. Unfortunately my debug code is too verbose so the messages from time of failure how scrolled off, even out of the .bak file.

    But a couple things. It would call makeWebRequest and every time, exactly 19 seconds later, I would get a failed response with error code -2.

    My run was through an area of spotty phone reception so it is possible this exasperated the problem. But the problem persists even now at home where there is no reception issue.

    I tried running the sample WebRequest widget and it too would not connect.

    The phone is definitely still connected as I'd get the little phone icon on the watch face.

    Both my app and the WebRequest widget start working after a reboot. Just connecting to the computer to download files is not sufficient to get it to reset.

    I'll continue to adjust my debug code to see if I can narrow down the timing and other things that might be happening.
  • With an error of -2....

    I have a few things where I show the error codes for a makeWebRequest, and when I see a -2, it seems to something like a "loss of Signal" where a request is sent, but before/during the response, the phone connection drops.. For example, I''ll see this is if after the request is sent but before the response is complete, I walk out of BT range.

    Maybe log phoneConnected when you get this error.

    What kind of phone are you using? Android or iPhone.
  • Former Member
    Former Member
    So, here's the section of code that I have that makes the call to makeWebRequest....

    if (Sys.getDeviceSettings().phoneConnected) {
    Comm.makeWebRequest(
    "https://url/v1/forecast.json?key="+apiKey+"&q="+location+"&days=2",
    {},
    {},
    method(:onReceive)
    );
    } else {
    Sys.println("Phone connection required.");
    }

    I don't think that I'm losing signal as the root cause. My watch is on my wrist while I sleep with my phone on my nightstand and when I wake up it may be "hung". Again, nothing changed on my end in months.

    Maybe I should add a counter to see how many successful calls are made before a fail call... maybe that would tell us something. Thoughts?
  • My phone is an iPhone 7. It isn't a phone connection issue. It might be started by a phone out of service range issue (unlikely given what I've seen, but need more data), but it shouldn't continue being an issue once there is clearly cell connection. But the whole time, the phone and watch are connected via BT. As I stated earlier, I don't even try making the call if there is no phone connected. The fact that the makeWebRequest won't resume working until a full reboot of the device indicates there is something wrong at a lower level. And as I pointed out, it's not just one app connecting to a single server. Once it fails, makeWebRequest won't work for any app until the reboot. The second the watch has been rebooted, the connections start working again.
  • Randy, sounds like exactly the same problem