Can you explain this, because I can't

From the method of a makeWebRequest in the Simulator for a Venu2.

Background: 15:35:29 : Requesting vehicle data from temporalEvent
Background: 15:35:30 : onReceiveVehicleData: 200
Background: 15:35:30 : Total memory: 61408 Used memory: 32008 Free memory: 29400
Background: 15:35:30 : onReceiveVehicleData: Reading as a string

This is the same thing from my Venu2

16:45:58 : Requesting vehicle data from temporalEvent
16:46:03 : onReceiveVehicleData: -403
16:46:03 : Total memory: 61416 Used memory: 25328 Free memory: 36088

And I'm reading the data as plain text because of that 403 and yet, it still creates 403??? The data received is a string of 6.5KB! And if it would have read correctly, it would have dropped the free space to around 29500, just like in the simulator. So why that 403?

This is the makeWebRequest call

    function makeTeslaPlainWebRequest(url, params, callback) {
		var options = {
            :method => Comms.HTTP_REQUEST_METHOD_GET,
            :headers => {
              		"Authorization" => _accessToken
					},
            :responseType => Comms.HTTP_RESPONSE_CONTENT_TYPE_TEXT_PLAIN
        };
		Comms.makeWebRequest(url, params, options, callback);
    }

Why is it doing that? I don't understand. What am I doing wrong here?

  • look into http traffic viewer, maybe it's not 6.5 but exceeds 8 and as I remember about 8 is the limit for respond

  • It's 0x1B1B, so 6939 bytes. My other app (widget, this one is a watch face) that reads the same data has no problem reading it in its background space.

    I though that maybe there was too much data in the background buffer (since the data is merged there when successfully read) but nope, a call to getBackgroundData returns null, so no data there either.

    I restored an earlier branch that was working (this new branch has a cleaner code for the background processes and onBackgroundData, or so I thought) and I'm painstakingly re-adding bits piece by piece to try and see when it starts doing that. I still can't see why it does that.

  • I don't know why you use getBackgroundData.

    getBackgroundData is needed when background is collecting data but you have only request and respond, so maybe this is a problem you add data to the previous and out of memory...

  • That was exactly what I was trying to see if there was data lingering there that would have caused it to tip over but nope. I added it as a debug step.

  • you can't debug it because error is out of your code...

    - A app creates B

    - B service delegate calls webreq in C

    - C system claims no memory and and returns to B 403 even you have 60 free in B

  • Yeah, I can see the data being received but onReceive call couldn't process it. I find it odd that 30KB was consumed between 'b' and 'c' though.

    Anyway, I noticed that the App Class had a bunch of stuff that could have easily been into the View Class instead so I moved it there and recuperated 2KB worth of Background space.

    I've reintroduced slowly the code that was giving me 403 errors and so far, all I get is 200. And I've consumed just 424 bytes of background space.

    This is the old code working (never got a 403 with it)

    Background: 23:15:16 : initialize:Getting vehicle data
    Background: 23:15:17 : onReceiveVehicleData: 200
    Background: 23:15:17 : Total memory: 61408 Used memory: 42816 Free memory: 18592

    This was withe the moving of stuff away from the App Class

    Background: 0:42:29 : initialize:Getting vehicle data
    Background: 0:42:29 : onReceiveVehicleData: 200
    Background: 0:42:30 : Total memory: 61408 Used memory: 40744 Free memory: 20664

    And this is with the reintroduction of most of the new code (but reformatted a bit)

    Background: 13:51:56 : onTemporalEvent: Getting vehicle data
    Background: 13:51:56 : onReceiveVehicleData: 200
    Background: 13:51:56 : Total memory: 61408 Used memory: 41168 Free memory: 20240