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

Push Notification to iOS issue #1730

Closed
3 tasks done
kwstasna opened this issue May 9, 2016 · 4 comments
Closed
3 tasks done

Push Notification to iOS issue #1730

kwstasna opened this issue May 9, 2016 · 4 comments

Comments

@kwstasna
Copy link

kwstasna commented May 9, 2016

Environment Setup

  • Server: parse-server version 2.2.7,
    operating system: Ubuntu 14.0.4, remote, Parse-Dashboard: 1.0.10
  • Database: MongoDB 3

Steps to reproduce

Hello. I'm trying to figure out how to make push notifications with Parse-Server from Parse-Dashboard.
My index.js file is this

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');

var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://username:pass@localhost:27017/parsedb',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'APPID',
  masterKey: process.env.MASTER_KEY || 'MasterKey', //Add your master key here. Keep it secret!
   push: {
      ios: [
              {
                pfx: __dirname + '/p12/DevCer.p12', // Dev PFX or P12
                bundleId: 'com.irem.sourtoukif',
                production: false // Dev
              },
              {
                pfx: __dirname + '/p12/ProdCer.p12', // Prod PFX or P12
                bundleId: 'com.irem.sourtoukif',  
                production: true // Prod
              }
            ]
    },
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  }
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('Make sure to star the parse-server repo on GitHub!');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
  res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

So i load and the Developer and the Production p12 files and i get this

verb parse-server-push-adapter APNS APNS Connection 0 Socket Error

While the badge is being increased in the Installation Class, i get no notification in my iPhone.
Any idea why?
Thanks!

Logs/Trace

verbose: POST /parse/push { host: '93.174.121.23:1337',
  connection: 'keep-alive',
  'content-length': '181',
  origin: 'http://93.174.121.23:4040',
  'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537                                              .36',
  'content-type': 'text/plain',
  accept: '*/*',
  referer: 'http://93.174.121.23:4040/apps/SourtoukiServer/push/new',
  'accept-encoding': 'gzip, deflate',
  'accept-language': 'en-US,en;q=0.8,el;q=0.6' } {
  "where": {},
  "data": {
    "alert": "adsad"
  }
}
verbose: {
  "headers": {
    "X-Parse-Push-Status-Id": "6b2vx5qxOu"
  },
  "response": {
    "result": true
  }
}
verbose: sending push to 1 installations
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
verb parse-server-push-adapter APNS APNS Connection 0 Disconnected

After using DEBUG=apn i get this

verbose: sending push to 1 installations
  apn Initialising connection +0ms
  apn Loading Credentials +2ms
  apn 1 left to send +6ms
  apn Raising error: +10s [Error: Connect timed out] undefined undefined
  apn Error occurred with trace: +1ms Error: Connect timed out
    at Connection.<anonymous> (/root/parse2/node_modules/apn/lib/connection.js:225:35)
    at Timer.listOnTimeout (timers.js:92:15)
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
  apn Initialising connection +1s
  apn 1 left to send +0ms
  apn Raising error: +10s [Error: Connect timed out] undefined undefined
  apn Error occurred with trace: +1ms Error: Connect timed out
    at Connection.<anonymous> (/root/parse2/node_modules/apn/lib/connection.js:225:35)
    at Timer.listOnTimeout (timers.js:92:15)
verb parse-server-push-adapter APNS APNS Connection 0 Socket Error

And if i leave it sometime on i get this error

verb parse-server-push-adapter APNS APNS Connection 0 Socket Error
  apn Raising error: +3ms { [Error: connect ETIMEDOUT 17.110.225.225:2195]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '17.110.225.225',
  port: 2195 } null undefined
  apn Error occurred with trace: +0ms Error: connect ETIMEDOUT 17.110.225.225:2195
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
  apn Destroying connection +0ms undefined
  apn Removing socket from pool +0ms undefined
  apn Socket closed +0ms undefined
  apn Removing socket from pool +0ms undefined

@bohemima
Copy link
Contributor

bohemima commented May 9, 2016

Any firewalls blocking traffic perhaps?

@kwstasna
Copy link
Author

kwstasna commented May 9, 2016

Yes dude i just figured out that port 2195 was being blocked by my firewall and i was just about to write it here so guys, be careful with firewall ! xD

@kwstasna kwstasna closed this as completed May 9, 2016
@acegreen
Copy link

@kwstasna Does the support differ for production vs dev? Because I seem to be getting the dev notifications but unsure if users are getting production push notifications.

@tenac1337
Copy link

^ Would like to know the answer to that as well, whether anything changes for production push notifications on production certificate?

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

4 participants