苹果推送通知在Erlang(或改进的Ruby?) [英] Apple Push Notification in Erlang (or improved in Ruby?)

查看:138
本文介绍了苹果推送通知在Erlang(或改进的Ruby?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Ruby的服务器上运行Apple Push Notification。我想在Erlang中找到一个,因为我想使用主管来监视它。有人有任何代码可以帮助我吗?



这是我的Ruby代码。有一件事我不喜欢这个当前的实现,它似乎并没有保持连接 - 它每天断开2-3次,似乎在我重新连接之后,第一个推送不会通过:

  context = OpenSSL :: SSL :: SSLContext.new 
context.cert = OpenSSL :: X509 :: Certificate.new(File.read (cert))
context.key = OpenSSL :: PKey :: RSA.new(File.read(cert))

def connect_sockets(服务器,上下文)
sock = TCPSocket.new(server,2195)
ssl = OpenSSL :: SSL :: SSLSocket.new(sock,context)
ssl.connect

return sock,ssl
end

sock,ssl = connect_sockets(server,context)#这被称为初始连接,并且每当断开连接时也重新连接。

如果Erlang Push不可行,那么只要坚持使用Ruby,就不要介意我可以保持我的关系,也可以通过Erlang进行监督。有人知道这是否有可能吗?

解决方案

这个关于苹果推送通知与Erlang的问题也可能对此有用。


I currently have an Apple Push Notification running on my server in Ruby. I'd like to get one going in Erlang as I'd like to use a supervisor to keep watch over it. Does anyone have any code that they could help me with?

Here's my Ruby code. One thing I do not like about this current implementation is that it does not seem to stay connected - it disconnects 2-3 times a day, and it seems after I reconnect that the first push will not go through:

context = OpenSSL::SSL::SSLContext.new
context.cert = OpenSSL::X509::Certificate.new(File.read(cert))
context.key = OpenSSL::PKey::RSA.new(File.read(cert))

def connect_sockets(server, context)
        sock = TCPSocket.new(server, 2195)
        ssl = OpenSSL::SSL::SSLSocket.new(sock,context)
        ssl.connect

        return sock, ssl
end     

sock, ssl = connect_sockets(server, context) # this is called to initially connect and also reconnect whenever disconnected.

If Erlang Push isn't doable then I wouldn't mind sticking to my Ruby one as long as I can keep my connections alive, and perhaps supervise it through Erlang. Does anyone know if any of this is possible?

解决方案

This question on Apple Push Notifications with Erlang might also be useful for this one.

这篇关于苹果推送通知在Erlang(或改进的Ruby?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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