Acknowledged

makeImageRequest ignores error returning from server

Whatever my server returns when error in onReceiveImage code is always 404.

In web bowser I can see value I return.

  • I looked at the code in the virtual machine and we appear to be passing along the response code that we receive.

    I believe the issue is related to the fact that image requests are redirected out to our image service for processing to avoid the need to transfer the original raw image over BLE and then do the conversion on a memory constrained embedded platform.

    My guess is that the web server hosting the image returns a response code other than 200, and the image service is generating a 404. I have zero knowledge about any of the inner workings of that service other than the actual image processing, so this is all just conjecture. We'll look into it.

  • In case of makeImageRequest http traffic shows nothing.

    Me too. Nothing was shown in http traffic. So frustrated with this.
    My code Is below. Always 404. 
    Garmin CIQ is really a buggy system.
    function downloadQR() as Void {
        System.println("downloadQR");
        
        var screenWidth = System.getDeviceSettings().screenWidth;
        var strUrl = "https://img.niulasong.com/qr-image.png";
    
        System.println("strUrl:" + strUrl);
    
        var maxWidth =
          screenWidth * (System.getDeviceSettings().screenShape == 1 ? 0.707 : 1);
        Communications.makeImageRequest(
          strUrl,
          null,
          {
            :palette => [Graphics.COLOR_BLACK, Graphics.COLOR_WHITE],
            :maxWidth => maxWidth,
            :maxHeight => maxWidth,
            :dithering => Communications.IMAGE_DITHERING_NONE,
            :packingFormat => Communications.PACKING_FORMAT_PNG,
          },
          new Lang.Method(self, :onReceiveImage)
        );
      }
    
      function saveStorage(key, value as Object) {
        try {
          Application.Storage.setValue(key, value);
        } catch (e) {
          if (e instanceof Lang.StorageFullException) {
            storageFull = true;
          } else {
            throw e;
          }
        }
      }
      function onReceiveImage(code as Number, data as Object) as Void {
        System.println("data:" + data);
        System.println("code:" + code);
    
        if (code == 200) {
          System.println("data:" + data);
          if (data instanceof String && "N".equals(data)) {
            saveStorage("INVALID_TOKEN", true);
            WatchUi.requestUpdate();
          }
          //Remember to keep this order
          //Cuz if we invert them, some devices with ciq3.x have no BitmapReference
          //has operator is heavy!
          if (
            data instanceof Toybox.WatchUi.BitmapResource ||
            (Toybox.Graphics has :BitmapReference &&
              data instanceof Toybox.Graphics.BitmapReference)
          ) {
            saveStorage("CODE", data);
            Application.Storage.deleteValue("INVALID_TOKEN");
            WatchUi.requestUpdate();
          }
        } else {
        }
      }
    }
  • Yes, dynamically but it doesn't matter how the image is returned, you have only 2 ways

    -returning stream

    -generating file and returning http redirect

    but in both, when I have  on my server e.g. exception or no enough memory my  http error is covered by 404.

    I want return e.g 992 and get this error on ciq  and show info to user PICTURE TOO BIG, DECREASE SIZE OF IMAGE IN DEFINITION.

    simple user friendly application and possiblity to give the user information how to solve problem.

  • So I understand, you are dynamically building the image?  Is that only when the image is requested, or are you doing it continually. Maybe build the image on a time driven basis, like every minute?

    Or use makeWebRequest to tell the server to prep the image and then use makeImageReqest to get the image?

  • I've a stream transfer to avoid keeping on server anything from user request (maybe somebody will put sensitive information).

    2 stages don't solve also problem because the same bug will appear in ... 2nd step, when taking file from server

    If you can't do thing good don't do it at all :-) User will see always 400, pity but it's not my bug  nobody has given me a chance to write the very good app, but maybe somebody will see this report and will fix it.