0

we are using $http.post to send a request to our server and when the server doesn't reply in time (approx 3 secs) our angularjs client send another http.post. We have tracked this with tcpdump and we see 2 different $http.post.

This is our controller:

var request = Local.testPost();
request.then(function successCallback(response) {
  console.log(response);
}, function errorCallback(error) {
   console.log(error);
});

And this is our Local Service post:

this.testPost = function(){
    var data = 'token='+User.getToken();

    var request = $http(
        {
            method: 'post',
            headers: {
               'Content-Type': 'application/x-www-form-urlencoded'
             },
            url: self.server+'/api/cmd',
            data: data
        }
    );
    return request;
};

Our server logs 2 different post too...

How is possibile? Thanks everybody!

UPDATE: Tcpdump Log

 16:53:38.058379 IP 192.168.1.66.52515 > 8.ip-xxxxxx.eu.http: Flags [P.], seq 581:1162, ack 355, win 4106, options [nop,nop,TS val 206302095 ecr 194158267], length 581: HTTP: POST /api/cmd HTTP/1.1

16:53:41.843608 IP 192.168.1.66.52515 > 8.ip-xxxxx.eu.http: Flags [.], ack 709, win 4095, options [nop,nop,TS val 206305864 ecr 194161726], length 0

16:53:41.848302 IP 192.168.1.66.52515 > 8.ip-xxxxx.eu.http: Flags [F.], seq 1162, ack 709, win 4096, options [nop,nop,TS val 206305868 ecr 194161726], length 0

16:53:41.848918 IP 192.168.1.66.52522 > 8.ip-xxxxxx.eu.http: Flags [S], seq 4161058194, win 65535, options [mss 1460,nop,wscale 5,nop,nop,TS val 206305868 ecr 0,sackOK,eol], length 0

16:53:41.884020 IP 192.168.1.66.52522 > 8.ip-xxxxxxx.eu.http: Flags [.], ack 3569763921, win 4117, options [nop,nop,TS val 206305903 ecr 194161768], length 0

16:53:41.884246 IP 192.168.1.66.52522 > 8.ip-xxxxxx.eu.http: Flags [P.], seq 0:581, ack 1, win 4117, options [nop,nop,TS val 206305903 ecr 194161768], length 581: HTTP: POST /api/cmd HTTP/1.1

16:53:41.884701 IP 192.168.1.66.52515 > 8.ip-xxxxxx.eu.http: Flags [.], ack 710, win 4096, options [nop,nop,TS val 206305903 ecr 194161768], length 0

16:53:45.629884 IP 192.168.1.66.52522 > 8.ip-xxxxxx.eu.http: Flags [.], ack 355, win 4106, options [nop,nop,TS val 206309616 ecr 194162704], length 0

16:53:54.452688 IP 192.168.1.66.52435 > 8.ip-xxxxxx.eu.http: Flags [.], ack 5234, win 4096, options [nop,nop,TS val 206318403 ecr 194164846], length 0

16:53:54.452696 IP 192.168.1.66.52435 > 8.ip-xxxxxx.eu.http: Flags [.], ack 5234, win 4096, options [nop,nop,TS val 206318403 ecr 194164846], length 0

16:53:54.452719 IP 192.168.1.66.52435 > 8.ip-xxxxxx.eu.http: Flags [F.], seq 1261, ack 5234, win 4096, options [nop,nop,TS val 206318403 ecr 194164846], length 0
20
  • What your developer tools network tab showing? Can you get a screenshot? Commented Jul 16, 2016 at 14:43
  • In the network tab i can only see one request sending... Commented Jul 16, 2016 at 14:44
  • In that case it might be something to do with the server. What your server stack? And is the behavior consistent will different browsers? Commented Jul 16, 2016 at 14:47
  • Our server stack is Nginx tornado4.3 python and yes we see this behavior also in an ionic app. Commented Jul 16, 2016 at 14:51
  • I have added a tcp dump log on our client Commented Jul 16, 2016 at 14:58

1 Answer 1

1

one possible cause could be if your server responds with 408 status, in this case some retry automatically run. You should not respond 408 if it's not a "real" 408.

have a look at this: https://github.com/angular/angular.js/issues/4806

cheers

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.