Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Intermittent Failed to Fetch - Server Shows Success 200

ANSWERED

I have companion code that is fetching JSON data from a REST service that I control.  Every now and then the fetch fails with the 'failed to fetch' error message. 

  • On the server I can see that the server process completed successfully and returned a 200 OK.
  • I'm gathering the logging information by POSTing data to the same server, and the log data goes through just fine with the failure message.
  • It fails sometimes on Wifi, sometimes on Cellular.  Good connections and mediocre connections.
  • I'm fetching data twice an hour, and it fails consistently once or twice a day.
  • If it fails, I can immediately make another request (manually on the watch) and I get a response. 

Any suggestions??  I'm trying to avoid programmatically making another request if fetch fails, since I don't want to add unnecessary calls to the server.  The only thing I can think of is that the request can take 4 or 5 seconds for the server to do what it needs to do before sending a response and that's causing an issue somehow.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Okay, it looks initially like the server was taking a long time to cold start, but not counting the cold start in the response time reported so I wasn't aware it was happening. 

 

With a faster response time I don't think I'm getting the failed to fetch anymore.  It looks initially like a response time of less than 10 or so seconds from the REST service is reliable.

 

Thanks for your help.

View best answer in original post

Best Answer
0 Votes
3 REPLIES 3

I had a chat with the mobile team leads about this today. It might be possible that the companion could be demoted while a long fetch() was processing.

 

Are you able to provide a small sample app which exhibits this behaviour?

 

Thanks

Best Answer
0 Votes

Thanks for getting back to me.

 

Since I posted this, I discovered that the server could potentially be taking more time to respond than I thought (maybe 30 seconds or so).  I've taken steps to remove this possibility.  I've just turned logging back on so the jury is still out on whether that fixed the "failed to fetch" issue.  I'm definitely still seeing an issue, but it could be something else.  More soon.

 

I do recall during testing that if I intentionally made the server take 20-30 seconds to respond that the fetch would fail.  I'm not sure if that's expected on a reliable connection.  If you need me to create a REST service that does nothing but wait 30 seconds before responding and an app to go with it I can do that, but I'm not sure if that's going to be necessary.

 

Thanks again.

Best Answer
0 Votes

Okay, it looks initially like the server was taking a long time to cold start, but not counting the cold start in the response time reported so I wasn't aware it was happening. 

 

With a faster response time I don't think I'm getting the failed to fetch anymore.  It looks initially like a response time of less than 10 or so seconds from the REST service is reliable.

 

Thanks for your help.

Best Answer
0 Votes