[Twisted-Python] Twisted hangs when using pyapns
Ni Wesley
nispray at gmail.com
Thu Oct 16 00:42:51 MDT 2014
I got the point.
server.py:
def write(self, notifications):
"Connect to the APNS service and send notifications"
if True: #not self.factory:
log.msg('APNSService write (connecting)')
with open('/tmp/wniapns.log','a') as f:
f.write("#"*20+"\n")
f.write("apns server1\n")
f.write("#"*20+"\n")
server, port = ((APNS_SERVER_SANDBOX_HOSTNAME
if self.environment == 'sandbox'
else APNS_SERVER_HOSTNAME), APNS_SERVER_PORT)
self.factory = self.clientProtocolFactory()
context = self.getContextFactory()
reactor.connectSSL(server, port, self.factory, context)
client = self.factory.clientProtocol
* if client:*
with open('/tmp/wniapns.log','a') as f:
f.write("#"*20+"\n")
f.write("apns server2\n")
f.write("#"*20+"\n")
return client.sendMessage(notifications)
else:
Problem is for twice push to one device, client is not None the second
time, code goes here and error then.
BTW, what I wanna ask is where is the default log file? I didn't see any
exception raised.
I haven't used pyapns and twisted before, I see twisted has lines like
log.msg("xx"), where is the default log file?
Thanks.
Wesley
2014-10-16 13:39 GMT+08:00 Glyph <glyph at twistedmatrix.com>:
>
> On Oct 14, 2014, at 6:27 PM, Ni Wesley <nispray at gmail.com> wrote:
>
> Hi,
> The code is from our partner, so currently I won't change their code
> until I address this issue.
> The used pyapns code is here: https://github.com/samuraisam/pyapns
> And start twisted service by command : twistd -r epoll web
> --class=pyapns.server.APNSServer --port=7077
>
>
> Could you please help have a look?
>
>
> OK, you made me curious ;).
>
> I looked through the code, and as it stands, I doubt my original
> hypothesis (a threading problem) is correct. Threads are used only in the
> client talking to the pyapns server, not the pyapns server's client talking
> to APNS, so they're probably not interfering with it.
>
> As far as I can tell, the ReconnectingClientFactory is set up properly.
> Have you looked at the logs? The one possibility I can think of just from
> examining the code is that the log messages before calling up to
> ReconnectingClientFactory.clientConnectionLost are raising an exception,
> causing the reconnection not to proceed. That would most likely show a
> traceback in the logs, though.
>
> <
> https://github.com/samuraisam/pyapns/blob/master/pyapns/server.py#L157-L164
> >
>
> Any clue?
>
> -glyph
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
--
我是nispray先生
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20141016/0d49ad2c/attachment-0002.html>
More information about the Twisted-Python
mailing list