Acknowledged
CIQQA-3210

Inconsistent handling of empty 200 OK responses between simulator and device (SDK 8.1.1, Epix 2 Pro)

I am using Communication.makeWebRequest to poll a REST API. The server appears to have an issue and intermittently returns an empty response instead of a JSON payload.

The response has HTTP/1.1 200 OK but includes Content-Length: 0.

In the simulator, this results in a responseCode of -400 (INVALID_HTTP_BODY_IN_NETWORK_RESPONSE).

However, on the actual watch, the responseCode is 200 and data is null.

I am using SDK 8.1.1 and testing on an Epix 2 Pro 47mm, both in the simulator and on the physical device.

The code for the app is available here: https://github.com/TheNinth7/ohg. Reproducing the issue requires access to a server that is protected by basic authentication. I'm happy to share the necessary credentials or details via direct message or another secure method to help reproduce the issue.

Parents
  • In this case is sounds like the real cause it the server you are using (200 with no data)

    Yes, the issue ultimately lies with the server, but that's beyond my control. For now, I need my app to handle it gracefully. That’s when I noticed the discrepancies.

    It could be related to the phone's operating system. I'm using iOS, where I observed the difference between the simulator and a real device. Other users have also encountered the -400 error on real devices - possibly on Android. I’ll follow up with them to confirm.

Comment
  • In this case is sounds like the real cause it the server you are using (200 with no data)

    Yes, the issue ultimately lies with the server, but that's beyond my control. For now, I need my app to handle it gracefully. That’s when I noticed the discrepancies.

    It could be related to the phone's operating system. I'm using iOS, where I observed the difference between the simulator and a real device. Other users have also encountered the -400 error on real devices - possibly on Android. I’ll follow up with them to confirm.

Children
  • If there is real data at times, maybe use the last real data when this situation comes up? Or display "00" or something like "?" when it does.  Treat 200+null or -400 the same as far as an error.

    Yes to all of the above. I cache the content to improve startup speed. Temporary errors are shown only as toast notifications. If an error persists for more than 10 seconds, it's treated as fatal and triggers a full-screen error message. So far this never happened with the error in question. If the issue isn’t resolved server-side, I may suppress the toasts entirely and ignore the error until it reaches that fatal threshold.

  •  If there is real data at times, maybe use the last real data when this situation comes up? Or display "00" or something like "?" when it does.  Treat 200+null or -400 the same as far as an error.