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

有多应用,多证书ApnsServiceImpl创建的问题 #8

Open
lizhitao0923 opened this issue Jul 8, 2014 · 6 comments
Open

有多应用,多证书ApnsServiceImpl创建的问题 #8

lizhitao0923 opened this issue Jul 8, 2014 · 6 comments

Comments

@lizhitao0923
Copy link

RamosLi,我的系统要向多个应用推送消息,每个应用都有一个证书,请问我是不是要为每个要推送消息的应用都生成一个ApnsServiceImpl实例?

@RamosLi
Copy link
Owner

RamosLi commented Jul 8, 2014

对,每一个证书对应一个ApnsServiceImpl实例,注意还需要调用下apnsConfig.setName(),给每个设置成不同的名称就OK了

@lizhitao0923
Copy link
Author

回复的真快,给力!不设置apnsConfig.setName()名称会出现怎样的问题?

@lizhitao0923
Copy link
Author

如果我将ApnsServiceImpl的实例放到一个Map当中,长时间不用后取出来还能连上apns服务器吗,会不会自动断掉?

@RamosLi
Copy link
Owner

RamosLi commented Jul 10, 2014

嗯,你完全可以把ApnsService的实例放到map里管理。TCP连接断掉后会重新连接,所以能确保发送成功

@lizhitao0923
Copy link
Author

谢谢~!我还请教一个问题,官网说“应该保持一份连接多个通知的APNs的链接。APNs会把多次并重复尝试建立的连接是为DOS攻击服务而拒绝建立链接”,这个指的是不多次SSLContext context = SSLContext.getInstance(protocol);初始化吗?因为我看你的程序当中每次发送消息的socket都关闭了。

@RamosLi
Copy link
Owner

RamosLi commented Jul 11, 2014

你再仔细看看吧,一条连接建立后会重复使用,直到出错或者IDLE超过一定时间才会重新建立。你是不是每发送一条,就调用了shutdown啊? shutdown是在Java进程退出时调用,或者不调也可以。

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

2 participants