Frage

I'm running a scheduled job in parse.com which sends an HTTP request to my server. When I check the response of my server everything is alright. I get this:

"POST /path/to/something HTTP/1.1" 200 2 "" ""

At the same time in Parse I get this:

"success/error was not called".

Another strange thing is that I get to see the response my server sent in the logs (response is 'OK'). It seems that 2 calls are being made with 2 seconds interval and the 2nd one always "gets" my servers response.

Here's a sample of what I get in the logs:

E2014-05-12T19:36:52.952Z] v11: Ran job checkAlive with:
  Input: {}
  Failed with: success/error was not called
I2014-05-12T19:36:54.619Z] OK

And here's my job code:

Parse.Cloud.job("checkAlive", function(request, response) {     
    Parse.Cloud.httpRequest({
        method: "POST",
        url: "http://someurl/dostuff",
        success: function(httpResponse) {
            console.log(httpResponse.text);
        },
        error: function(httpResponse) {
            console.log('Request failed with response code ' + httpResponse.status);
            console.error('Request failed with response code ' + httpResponse.status);
        }
    });
});
War es hilfreich?

Lösung

You need to call status.success() or status.error() to complete the background job properly

so something like:

    success: function(httpResponse) {
        status.success(httpResponse.text);
    },
    error: function(httpResponse) {
        status.error('Request failed with response code ' + httpResponse.status);
        console.error('Request failed with response code ' + httpResponse.status);
    }

see: http://blog.parse.com/2013/09/04/introducing-background-jobs/

Hope it helps

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top