Reputation: 4054
I need to send push notification using a control panel from server.
The server is a Linux virtual Cloud box which is behind a proxy. The control panel is designed using J2EE with Tomcat
I am using JAVA based https://github.com/notnoop/java-apns/releases API for push
The code
ApnsService service = APNS.newService().withSandboxDestination().withCert("mycert.p12", "mypassword").build();
String messageTobeSent = APNS.newPayload()
.alertBody("Message with badge 2")
.badge(2)
.alertTitle("Message with badge 2")
.sound("ding.wav")
.build();
service.push("d81f0080ed7bf05ac96261dc1805fbf00230073f606f1388a644469b1893446f", messageTobeSent, new Date());
I am getting an error Couldn't connect to APNS server, My Questions are
Upvotes: 0
Views: 2935
Reputation: 4054
Answering your 3rd Question which will solve the first two questions regardlessly. NotNoop Java-Apns definitely supports proxy.
Refer the Java Doc provided ApnsServiceBuilder withProxy(java.net.Proxy)
Specify the proxy to be used to establish the connections to Apple Servers
In your code you can put as following
ApnsService service = APNS
.newService()
.withSandboxDestination()
.withProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("<your proxy host>", <your proxy port>)))
.build();
Now the library itself will connect via proxy
Upvotes: 0
Reputation: 854
Yes You APNS client is unable to connect to the APNS server form that machine. Please test TCP connectivity to the APNS server from the machine where your application is running. You can use nc command to test connectivity to APNS server from your linux box. Yes APNS has nothing to do with proxy as APNS conection works over TCP. If you can configure your firewall to connect to APNS then it should work.
nc apns_server_host apns_server_port
Upvotes: 0