GCM push notifications not received through proxy server

I am developing a small application for my course project (similar to Snapchat) that allows you to send and receive images and videos. I am using a BaaS called Parse, which uses GCM to deliver push notifications. However, the problem is that my campus uses a proxy network, due to which many applications do not work (WhatsApp, Instagram), while some applications (Snapchat) work, but their notifications are not delivered. The same thing happens with my application.

Is there any possible way to overcome this problem, assuming that I do not affect the proxy network, and there are no options on the cellular network.

enter image description here

+4
source share
3 answers

It all depends on the campus network access policy. You cannot do this if your Campus proxy firewall does not provide access to these sites. However, you can ask them to allow this URL through their proxy server.

Or simply you can use some other external proxy server by adding lines to your code

System.setProperty("https.proxyHost", "<IP>"); System.setProperty("https.proxyPort", "<Port>");

where are you trying to connect the Google API. Say if you use something like this,

 URL url = new URL("https://android.googleapis.com/gcm/send"); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "application/json"); conn.setRequestProperty("Authorization", "key="+<your api key>); 

Before these lines, where you are trying to connect to the Google APIs, add the proxy settings lines, the above two lines. Also, try with a proxy server on campus, as well as with another external proxy server, you will find out that the problem is with your proxy server on the campus or not.

Try this, hope this helps with your problem .. !!!!!

+4
source

Use something like this,

 import com.google.android.gcm.server.Sender; public class ProxySender extends Sender { public ProxySender(String key) { super(key); // TODO Auto-generated constructor stub } @Override protected HttpURLConnection getConnection(String url) throws IOException { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("<YOUR SERVER IP>", YOUR PORT)); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(proxy); return conn; } } 
+2
source

According to Google, in order to get GCM, we have to open several ports. below,

“If your organization has a firewall that restricts traffic to the Internet or from the Internet, you need to configure it to be able to connect to GCM so that your Android devices receive messages. The open ports are: 5228, 5229, and 5230. GCM usually only uses 5228, but sometimes it uses 5229 and 5230. GCM does not provide specific IP addresses, so you must allow the firewall to accept outgoing connections with all IP addresses contained in the IP blocks listed in Google ASN 15169. "

Are you trying to send GCM through parsing SDK? can you access these urls?

+2
source

All Articles