Complete
over 3 years ago

WERETECH-10904

We don’t plan to revert this change to Garmin Connect Mobile because it was not a documented requirement that the makeImageRequest API work with a mobile service, but we will consider the use case for future API improvement.

Connect Mobile 4.40 makeImageRequest localhost error

Hello, I have a small Garmin app, that connects to my Android phone who has a running http server that serves png images by url get encoding: Example http://127.0.0.1:9977/?imageId=9154752

So far, everything was working like a charm, but after updating to Android Garmin Connect Mobile 4.40 it stop working. The makeImageRequest returns a BLE_HOST_TIMEOUT as a responseCode and never downloads the image. Also debugging the Android http server, never receives the request for any picture. (Other requests such as webRequests are properly received as explained bellow, but not imageRequest)

 // Set up the responseCallback function to return an image or null
    function responseCallback(responseCode, data) {
        responseCode = responseCode;
        if (responseCode == 200) {
            image = data;
        } else {
           System.println(Lang.format("Error code $1$",[responseCode]));
           image = null;
        }
    }

    // wrap the request in a function
    function requestImageinGallery(imageId) {
        var url = "http://127.0.0.1:9977/";           // set the image url
        var parameters = { "imageId" => imageId};     // set the parameters
        var options = {                                         // set the options
            :palette => [ Gfx.COLOR_ORANGE,                     // set the palette
                          Gfx.COLOR_DK_BLUE,
                          Gfx.COLOR_BLUE,
                          Gfx.COLOR_BLACK ],
            :maxWidth => 200,                                   // set the max width
            :maxHeight => 200,                                  // set the max height
            :dithering => Communications.IMAGE_DITHERING_NONE   // set the dithering
        };

        // Make the image request
        Communications.makeImageRequest(url, parameters, options, method(:responseCallback));
    }



The makeWebRequest works perfectly and receives the response from the the httpServer as is running.

 function checkIfServerIsRunning() {
      
  var url = "http://127.0.0.1:9977/";           // set the image url
  var params = { "check" => "isAlive"};     // set the parameters

   var options = { // set the options
    :method => Communications.HTTP_REQUEST_METHOD_GET, // set HTTP method
    :headers => { // set headers
    "Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON}, // set response type
    :responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON };
    
    Communications.makeWebRequest(url, params, options, method(:onReceive)); }



Can anyone help me?

PS: I did create a small webserver ngnix/node.js online to test it, with the same configuration as my android HttpServer. And accessing it by IP, same as above with (just changing the ip), with same port number, and request parameters, it works perfectly. There must be something with 127.0.0.1 that is blocked (I also tested with http://localhost, and does not work either).

Thank you in advance.

Parents
  • There doesn't seem to be any simple and quick workaround available by using makeWebRequest() to fetch a bitmap resource from localhost. Even if I do try to encode the bitmap into Base64 string on my server side and receive the bitmap through plain text using makeWebRequest(), it doesn't seem to be possible to convert that byte array into a BitmapResource to be able to be drawn on screen using drawBitmap(). My bitmaps are always 1-bit in my app so what if I can encode it in my way and draw it using drawPoint(), but even by thinking of it I feel it's very ridiculous. I as a CIQ developer I feel ashamed I even chose to develop on this platform. Frustration everywhere.

Comment
  • There doesn't seem to be any simple and quick workaround available by using makeWebRequest() to fetch a bitmap resource from localhost. Even if I do try to encode the bitmap into Base64 string on my server side and receive the bitmap through plain text using makeWebRequest(), it doesn't seem to be possible to convert that byte array into a BitmapResource to be able to be drawn on screen using drawBitmap(). My bitmaps are always 1-bit in my app so what if I can encode it in my way and draw it using drawPoint(), but even by thinking of it I feel it's very ridiculous. I as a CIQ developer I feel ashamed I even chose to develop on this platform. Frustration everywhere.

Children
No Data