Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Received an error with invalid JSON from Parse: Cannot POST /push\n Error code 107 #1335

Closed
3 tasks done
hafizapp opened this issue Apr 2, 2016 · 8 comments
Closed
3 tasks done

Comments

@hafizapp
Copy link

hafizapp commented Apr 2, 2016

Check out this issue for an ideal bug report. The closer your issue report is to that one, the more likely we are to be able to help, and the more likely we will be to fix the issue quickly!

For implementation related questions or technical support, please refer to the Stack Overflow and Server Fault communities.

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Environment Setup

Every thing okay, except push notification.

Steps to reproduce

screen shot 2016-04-02 at 3 43 00 pm

main.js -->

Parse.Cloud.define("sendPush", function(request, response) {

    var sendUserId = request.params.userId;
        var msg = request.params.message;

    var query = new Parse.Query(Parse.Installation);
    query.equalTo('userId', sendUserId);

        Parse.Push.send({
                query: query,
                data: {
                        alert: msg,
                        sound: 'default'
                }
        }, {
                success: function() {
                        // Push was successful
                        response.success("Push sent");
                },
                error: function(error) {
                        // Handle error
                        response.error(error);
                },
                useMasterKey: true
        });
});

index.js -->

var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '',
masterKey: process.env.MASTER_KEY || '', 
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',

push: {
android: {
senderId: 'my id',
apiKey: 'my apiKey'
},

ios: [{
pfx: '/push/Certificates_Dev.p12', // Dev PFX or P12
bundleId: 'my_bundle_id',
production: false // Dev
},
{
pfx: '/push/Certificates_Prod.p12', // prod PFX or P12
bundleId: 'my_bundle_id',
production: true // Prod
}]
}
});

Logs/Trace

Please help...

@flovilmart
Copy link
Contributor

Can you run parse-server with environment variable VERBOSE=1 in order to get the request/response content?

@flovilmart
Copy link
Contributor

Also can you try replacing response.success("Push sent"); by response.success();

@hafizapp
Copy link
Author

hafizapp commented Apr 3, 2016

@flovilmart
Just tried by replacing response.success("Push sent"); by response.success();

and same error got.

[Error]: { code = 107; message = "Received an error with invalid JSON from Parse: Cannot POST /push\n"; } (Code: 141, Version: 1.12.0)

I have also added the environment variable VERBOSE=1, how can I see the debug log.

@flovilmart
Copy link
Contributor

the debug logs should be printed in the console when you server runs; what's the serverURL value? seems related to #1337 somehow

@hafizapp
Copy link
Author

hafizapp commented Apr 3, 2016

Uploading Screen Shot 2016-04-03 at 11.33.12 PM.png…
@flovilmart
Except push notifications, all other things working cool.

Server URL should be
https://****.herokuapp.com/parse
or
https://**
**.herokuapp.com
?

@flovilmart
Copy link
Contributor

No, the serverURL should be the local loop with http://localhost:PORT/parse, but it could work with the publicly accessible URL

@hafizapp
Copy link
Author

hafizapp commented Apr 3, 2016

It's resolved, Thank @flovilmart.

I had used https://**.herokuapp.com instead of https://**.herokuapp.com/parse

@JpChii
Copy link

JpChii commented May 3, 2019

It's resolved, Thank @flovilmart.

I had used https://**.herokuapp.com instead of https://**.herokuapp.com/parse

Hi hafizapp,
After changing the url i am still facing the same issue, could you help??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants