05-16-2018 18:10 - edited 05-16-2018 18:10
05-16-2018 18:10 - edited 05-16-2018 18:10
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.
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.
Answered! Go to the Best Answer.
05-19-2018 06:11
05-19-2018 06:11
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.
05-17-2018 15:53
05-17-2018 15:53
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
05-17-2018 17:29
05-17-2018 17:29
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.
05-19-2018 06:11
05-19-2018 06:11
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.