通过代理谷歌云通讯GCM [英] Google cloud messaging GCM through proxy

查看:360
本文介绍了通过代理谷歌云通讯GCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦通过公司代理发送消息给设备。
我已经做了谷歌网站的GCM教程,并已成功地与Android模拟器注册的设备谷歌的服务器上, 而服务器在我结束也。
为此,我不得不去通过公司的代理,在仿真器的接入点设置它。 现在,这个问题我已经发出了一个消息从我的服务器到设备通过同一代理。 我使用从演示该servlet code,它使用了

I am having trouble sending a message to a device through the company proxy.
I have done the GCM tutorial on the google site and have successfully registered a device on the google servers with the android emulator, and also on the server at my end.
For this I had to go through the company proxy, setting it in the access point of the emulator. Now the problem I have is sending a message from my server to the device through the same proxy. I am using the servlet code from the demo which uses the

com.google.android.gcm.server.Sender

辅助类来发送邮件。

helper class to send the message.

我在Tomcat 7运行的servlet。

I am running the servlets on tomcat 7.

我已经尝试设置代理了在catalina.properties文件,像这样。

I have tried setting the proxy up in the catalina.properties file like so.

http.proxyHost=proxy.company.com  
http.proxyPort=8080

和我已经尝试设置servlet本身就像下面的内部属性。

And I have tried setting properties inside the servlet itself like below.

System.setProperty("http.proxyHost", "proxy.company.com");  
System.setProperty("http.proxyPort", "8080"); 

但我仍收到超时。 我知道它的公司代理,因为我得到的消息在家里工作,我有没有代理。

But still I get the timeout. I know its the company proxy because I got the messaging working at home where I have no proxy.

我已经看到了在Java code创建一个代理对象,然后用它创建的连接,但我不认为这是有用的,因为在这里我使用发件人辅助类来发送邮件。

I have seen a proxy object created in the java code and then a connection created with it, but I dont think that is usable here since I am using Sender helper class to send the message.

这是失败的超时就行了。

This is the line that fails in a timeout.

Result result = sender.send(message, registrationId, 5);

任何帮助将是AP preciated。

Any help would be appreciated.

问候

比尔

推荐答案

好吧,我终于有工作。在我的评论我说过,我已经成功地发送了消息,但仿真器不是recieving它。我忘了按照我自己前面的建议,并与设置,像这样的代理参数运行命令行模拟器:

Alright, I finally have it working. In my comment I mentioned that I had succeeded in sending out the message, but the emulator was not recieving it. I had forgotten to follow my own earlier advice and run the emulator from the command line with the proxy parameters set like so:

emulator.exe -avd avd22google -http代理proxy.company.com:8080 -debug代理

emulator.exe -avd avd22google -http-proxy proxy.company.com:8080 -debug-proxy

总结一下,我最初的问题是,我已经注册的模拟器有GCM和我的本地服务器,但是当我点击发送消息我得到一个超时。

So to summarise, my initial problem was that I had registered the emulator on the with GCM and with my local server, but the when I clicked send message I was getting a timeout.

我最初以为是防火墙,所以我做了一些研究,并成立了雄猫catalina.properties文件的代理。 这并没有区别。

I initially thought it was the firewall so I did some research and set up the proxy in tomcats catalina.properties file. This made no difference.

我用了查尔斯网络代理的调试器软件上看到消息,正在试图发送给它想出了的https:/ /android.googleapis.com:443

I used the "Charles" web proxy debugger software to see where the message was attempting to be sent to and it came up with https://android.googleapis.com:443

所以,我最初我增加了以下我catalina.properties文件:

So I initially I added the following to my catalina.properties file:

https.proxyHost=proxy.company.com  
https.proxyPort=443

它仍然没有奏效。我的一个同事告诉我,我们公司代理处理各类通过端口8080的请求,所以我改变了对poort行:

It still did not work. A colleague of mine told me that our company proxy handles all types of requests through port 8080, so I changed the the poort line to:

https.proxyPort=8080

此允许消息被发送出去。 但随后该消息没有得到通过仿真器和我收到的LogCat中下面的错误。

This allowed the message to be sent out. But then the message was not getting through to the emulator and I was receiving the following error in LogCat.

[GTalkConnection.12] doConnect: caught XMPPError connecting to mtalk.google.com:5228.: -- caused by: java.net.SocketException: The operation timed out

我想起你需要开始使用命令行模拟器得到它使用代理。一旦我这样做洪水的消息出现在我的模拟器!

Then I remembered that you need to start the emulator with the command line to get it to use the proxy. Once I did this a flood of messages appeared on my emulator!

所以,我终于有工作端到端的。这是我花一个星期左右拿到GCM我公司防火墙内的全面工作,所以希望这篇文章可以帮助其他一些可怜的草皮在将来这样做。

So I finally have it working end to end. It's taken me about a week to get GCM fully working within my company firewall, so hopefully this post can help some other poor sod doing this in the future.

欢呼声

比尔

这篇关于通过代理谷歌云通讯GCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆