0
votes

After working with Parse for a considerable time on multiple project I recently started moving data to a local Parse server and writing a sample app to get familiar with the system. I managed to get most working so far including Push using het Parse Dashboard.

Unfortunately I can't seem to get Parse Push to work using cloud code.

This is my code:

Parse.Cloud.define('push', function(req, res) {
    var logMessage = "Push test";
    console.log(logMessage);
    var pushQuery = new Parse.Query(Parse.Installation);


    Parse.Push.send({
        where: pushQuery,
        data: {
        alert: 'Test'
    }
    }, {
        useMasterKey: true,
        success: function() {
        // Push sent, send re
        res.success('Push Sent');
        var logMessage = "Push Sent!";
        console.log(logMessage);

    },
    error: function(error) {
        res.error(error)


        var logMessage = error;
        console.log(logMessage);
        // There was a problem :(
    }
    });


    var logMessage = "Push should be sent.";
    console.log(logMessage);

});

Unfortunately no push is sent and the following error message is returned:

  {
  code: 107,
  message: 'Received an error with invalid JSON from Parse: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p>The requested URL /push was not found on this server.</p>\n<hr>\n<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 80</address>\n</body></html>\n' }

It seems to indicate the push request is sent to the /push directory of the main server, however I have no clue how I can change this to the appropriate location and I presumed parse-server would automatically choose the right path.

I hope someone might know how to fix this because I'm out of ideas at the moment..

1
That error message is coming from an Apache server running on port 80. Are you making a connection to the wrong address or port?... Take a look and make sure your server configuration is correct, and please provide code and details around a specific issue you're having.Did you set serverURL parameter correctly? by default it is set to api.parse.com/1 - Anbarasi
Thanks for the reply. I checked some configuration settings and I found out cloud code didn't have the right serverURL.. Strange that the other services seemed to work out fine though. I changed the URL to the appropriate setting and now it seems to work just fine! - Dannyvdz

1 Answers

0
votes

For all that deal with this same issue, here is the solution.

Thanks to Anbarasi for the correct answer. My server settings were incorrect. Upon changing the server URL to the correct settings (address + port) everything started working!