Odd issue with ajax request


Ok, so this is an odd one but with 2.9.1 ( guessing 2.9 as well), everything up to date my ajax request seem to be timing out.

What is odd, is that when I have wifi on everything loads up as expected but when on-network the request are very slow and frequently timeout.

I tested downgrading the ‘request’ module to two version below the current and that seems to work better but I did still see an issue where the ajax request will just fail, even though everything is up and running just fine ( we connect to a CDN to pull JSON and Images )

My mobile network is working fine as I have done speed tests etc.

So the question is, is there something I need to update to make this work reliably?

Basically, when a user enters in an ID it checks the code, if valid pulls the resources based off the CDN, right now it does make a number of XHR request, tryed putting everything in callbacks to see if maybe a max requests was getting hit (never had this issue before) but I’m still seeing odd behaviour when on a mobile network.

As an example, I have a link that will grab a survey, this makes a small ajax call to pull the survey details, when I click on the link it will sometimes just fail, no error response from the server just a ‘Timeout’ of the request however the CDN is returning things just fine…

I have also added the CDN to the allowed URLs just to test but it seems very unreliable right now.

That is odd.

Is this on Android or iOS or both?

Are these requests made using the browser’s built-in XMLHttpRequest object or are you making them through the forge.request API?

If it’s XMLHttpRequest then the problem is likely with something Apple or Google has changed with WebKit which is not something we have any control over.

Otherwise, the last major change we made to the forge.request module’s networking code was in 2017 when we stopped using the external AFNetworking framework in favor of Apple’s then-new NSURLSession classes and updated the version of OkHttp we use for Android.

So I’m using the forge request module, have been for a long while. It’s really weird as it seems to only impact android while on wireless network ( wifi seemed to work just fine )

What is also odd, is that today it seems to be working ok… Crazy because it was only on the cell network and everything else was loading just fine… Guess I will keep monitoring it.

Side note, you know of a good way to tail the xjax requests? Chrome dev tools don’t monitor that, also was wondering if you could explain a bit more how forge ajax works, is it making an XHR request via the browser or is it dropping into another protocol?

Just curious because I know browsers have a limit to the number of request it can have at the same time so not sure if this applies here too ( hence putting a callback into my script to run the request a bit more synchronously without blocking)

forge.request calls don’t use the browser’s API’s.

On Android we make use of the OkHttp client library while iOS uses Apple’s NSUrlSession API’s.

It’s hard to say what the limits are for forge.request as I haven’t taken the time to torture test it.

I imagine it’s around the same overhead as the browser. In fact, on iOS WKWebView also uses NSUrlSession internally.

re: slow performance on cellular network - it may just be that your service provider is overly congested?

In our neck of the woods our mobile data speeds plummeted through the floor when Covid hit with everyone working from home. :stuck_out_tongue: