0

I am facing an issue the http get call going into pending state, basically i am hitting the server for that http get call after every 5 seconds, that call getting latitude and longitude from server and rendering map based on those lat lng. The problem is call most of the time goes into pending state and making queue of that specific call because that call have to be called after every 5 seconds, one call stuck the others all dependent to that also stuck, the reason is javascript is a single threaded language, which will wait for a call to complete and run next when previous completed.

Kindly guide me How to debug that problem.

enter image description here

Umar Rasheed
  • 4,323
  • 4
  • 16
  • 26
  • Please share use some Code and Screenshots of your Networkcalls. –  Apr 11 '17 at 07:52
  • Angular is perfectly capable of making asynchronous calls to a webserver. Have you looked at this http tutorial? https://angular.io/docs/ts/latest/tutorial/toh-pt6.html – Stefan Apr 11 '17 at 07:54
  • @Stefan no, let me read that . – Umar Rasheed Apr 11 '17 at 07:57
  • @lukasrein97 `Get_tracking_info(id){ return this.http.get('URL/'+id+'/track',{headers: this.Get_Header()}); }` – Umar Rasheed Apr 11 '17 at 08:04
  • http.get is an asynchronous, you should not assume that it should return the results within 5 second. Because it is async, it may be longer than 5 second to fetch the result from the server. You may need to return observable from your factory and then subscribe the method after the response has been finished. – digit Apr 11 '17 at 08:11
  • @digit now i am just returning the response and subscribed to that, could you provide any example related as you described return observable from factory? – Umar Rasheed Apr 11 '17 at 08:15
  • @lukasrein97 please have look on screen short i taken while pending status from network tab. – Umar Rasheed Apr 11 '17 at 09:05
  • @UmarRasheed, is 1.9 min response time ? Also your every 5 sec call may result in server thinking that its scrapper or attack – N0mi Apr 11 '17 at 12:56
  • @N0mi so what should i need to do? – Umar Rasheed Apr 11 '17 at 15:03
  • If you don't own the server side, better make a batch queries or check with provider, how frequent can you make the call. – N0mi Apr 12 '17 at 00:39
  • @N0mi if i own the server side, what i can do for that to resolve pending issue because back end his written in ROR? – Umar Rasheed Apr 12 '17 at 05:48
  • Did you check that ? http://stackoverflow.com/questions/5585918/what-does-pending-mean-for-request-in-chrome-developer-window – N0mi Apr 13 '17 at 04:54
  • @N0mi yes checked that, – Umar Rasheed Apr 13 '17 at 11:57

0 Answers0