logicalparadox / apnagent

Node.js adapter for Apple Push Notification (APN) Service.
http://logicalparadox.github.io/apnagent
216 stars 38 forks source link

Can't use agent on openshift server #35

Closed dnnagy closed 9 years ago

dnnagy commented 9 years ago

I'm developing a website , that should send push notifications to iOS devices. On my localhost apnagent works fine, but when I git push it to Openshift cloud I get the following errors in the terminal:

remote: Waiting for application port (8080) become available ...
remote: Application 'apnagent' failed to start (port 8080 not available)
remote: -------------------------
remote: Git Post-Receive Result: failure
remote: Activation status: failure
remote: Activation failed for the following gears:
remote: 55c3344c89f5cf720xxxxxxx (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/55c3344c89f5cf720xxxxxxx/nodejs
remote: #<IO:0x00000000f1c278>
remote: #<IO:0x00000000f1c200>
remote: )
remote: Deployment completed with status: failure
remote: postreceive failed
To ssh://55c3344c89f5cf720xxxxxxx@apnagent-xxxxxxx.rhcloud.com/~/git/apnagent.git/
   bbcf2a3..87exxxx  master -> master 

My package.json looks like this:

{
  "private": true,
  "name": "apnagent",
  "version": "0.0.0",
  "dependencies": {
    "apnagent": "1.0.x"
  },
  "engines": {
    "node": ">=0.10.22",
    "npm": ">=1.3.14"
  },
  "scripts": {
    "start": "node agent/_header.js"
  },
  "main": "agent/_header.js"
}

I think i should use somehow process.env.OPENSHIFT_NODEJS_PORT as port on the server, or something like this. I'm sure, I've done some configuration mistake since on my local machine everything works fine.

pasupulaphani commented 9 years ago

same issue. Any solution?

ExploreMqt commented 9 years ago

I can't say that I've tried OpenShift, but I've been using Heroku without any issues for a few months. Can you post some example code on how you construct your agent object?

On Tue, Oct 13, 2015 at 8:53 PM, Phaninder Pasupula < notifications@github.com> wrote:

same issue. Any solution?

— Reply to this email directly or view it on GitHub https://github.com/logicalparadox/apnagent/issues/35#issuecomment-147894126 .

rahul-lohra commented 9 years ago

same issue, Exactly same error activating gear

ajostergaard commented 9 years ago

This might help: https://developers.openshift.com/en/node-js-environment-variables.html

rahul-lohra commented 9 years ago

Thank you @ajostergaard for quick reply , i have tried your solution it is working perfectly . But when i include package body-parser and morgan , it results the same error

my code: var express = require('express'); var bodyParser=require('body-Parser'); var morgan=require('morgan'); var app = express(); var http = require('http');

app.use(bodyParser.urlencoded({extended:true})); app.use(bodyParser.json()); app.use(morgan('dev'));

app.get('/', function (req, res) { res.send('Hello World!'); });

var ipaddress = process.env.OPENSHIFT_NODEJS_IP; var port = process.env.OPENSHIFT_NODEJS_PORT; if(typeof ipaddress === "undefined"){ ipaddress = "127.0.0.1"; port = 3000; } app.listen(port, ipaddress, function() { // Do your stuff console.log("Your server is running on: "+ipaddress+" port:"+port); });

if i comment out all the packages excluding express, it works fine ...

ajostergaard commented 9 years ago

@iamdangerous I suggest making sure it works locally before trying it on openshift however clearly not an apnagent issue.

@kommancs96 i suggest closing this issue.

rahul-lohra commented 9 years ago

well its working 100% fine in local machine, please look at this post (the answer) , i want to know is there any to use node version 0.12.X , i mean the latest version in server side (on openshift), i think may be node 0.10 (running on openshift) doesn't support latest packages, thats why i am this issue

ajostergaard commented 9 years ago

Be that as it may this has nothing to do with apnagent.

Have you tried node 10 on your local machine?

rahul-lohra commented 9 years ago

@ajostergaard thanks for keeping patience , and helping me everytime, i am an idiot, i was ignoring it all the time ,it was my silly mistake my 2nd line of code -->var bodyParser=require('body-Parser');<-- this was creating issue, i was importing wrong package all the time the package should be 'body-parser' (case-sensitive) .. Now , everything is working fine locally and remotely . Again thanks for your help .

srvsud commented 8 years ago

most of the times this issue occurs because of the error in scripts or compilation silly human errors :)