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

APN not working when using with nginx(proxy) #525

Closed
dilipzotha opened this issue Feb 14, 2017 · 2 comments
Closed

APN not working when using with nginx(proxy) #525

dilipzotha opened this issue Feb 14, 2017 · 2 comments

Comments

@dilipzotha
Copy link

dilipzotha commented Feb 14, 2017

Hi,

Since my app servers are behind firewall, I am using nginx for proxying request to apn. I am using tcp proxy_pass.

edited endpoint node_modules/apn/lib/config.js

let EndpointAddress = {
  production: "127.0.0.1",
  sandbox:    "api.sandbox.push.apple.com"
};


And port

let config = {
      token: null,
      cert: "cert.pem",
      key: "key.pem",
      ca: null,
      pfx: null,
      passphrase: null,
      production: (process.env.NODE_ENV === "production"),
      address: null,
      port: 10998,
      rejectUnauthorized: false,
      connectionRetryLimit: 10,
    };

config passed to apn:-

{
      token: {
        key: path.join(__dirname, "../config/apn/prodAuthKey.p8"),
        keyId: "XXXXX",
        teamId: "XXXX",
      },
      production: true,
}


Code for sending APN:-

const apnProvider = new apn.Provider(config.apnOptions);
const sendAPN = (message, state) => {
  let note = new apn.Notification();
  note.expiry = config.defaultTimeToLive;
  note.sound = "ping.aiff";
  note.alert = message.body;
  note.payload = message.transaction;
  note.topic = config.iosPackageName;
  apnProvider.send(note, state.customer.gcmId)
      .then(res=>{console.log(res)})
      .catch(err=>{console.log(err)});
}


I am unable to send apn. apnProvider.send doesn't give any result. When checked in nginx logs I am getting

upstream server temporarily disabled while connecting to upstream

TCP Proxy configured in nginx looks like this

stream {
    server {
        listen 127.0.0.1:10998;
        proxy_pass api.push.apple.com:443;
        error_log  /usr/local/var/log/nginx/apn.log info;
    }
}
@snarielwala
Copy link

Hi Dilip, Were you able to resolve this issue? I have been facing a similar problem.

@pewh
Copy link

pewh commented Feb 2, 2018

I face same issue too. Does anyone able to resolve this?

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