Quantcast
Channel: Appcelerator Developer Center Q&A Tag Feed (freezes)
Viewing all articles
Browse latest Browse all 6

Httpclient loop makes all responses from server return null after a random time

$
0
0

Hi there,

I've got a difficult one.

I'm emulating a chat and before being able to use push messages, i make my app read the chat database in a loop, but this loop randomly freezes the access to the server or just makes any mobile to get a null response from the server (when it starts then its always null forever). It also freezes the app sometimes.

This is the code in case i'm doing something very weird someone can tell me:

function CheckChat()
    {
        var xhr = Titanium.Network.createHTTPClient(
            {
                onload: function(e) {
                    AddComment(this.responseText); //Writes new chat line
                    setTimeout(CheckChat,5000); // sets a new refresh for 5 seconds later
                },
                onerror: function(e){ alert('Communication error while Checking the Chat');}
            }
        );
 
        xhr.open('POST','url', true); // i've tried with true and false
        xhr.send({
            UserID: Ti.App.Properties.getString('UserID'), //I send the userID to know which lines should the response have
        }); 
    }
Maybe the httpclients are overlapping themselves somehow? How can i prevent this if this is the case?

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>