APNSwift: Connection Deadlock caused by missing response & no timeout

Background I’m building a push service on Ubuntu 18.04 with Vapor 4 & Vapor/apns, using tls authentication. The service is nothing but sending a push to my device after several hours and then another push, running on Apple’s sandbox push environment.

The Bug After sometime, I found the push service will eventually fall into connection deadlock error reported as [ ERROR ] Connection request timed out. This might indicate a connection deadlock in your application.

After some investigation, I found it’s the previous push which was sent some time ago, not getting its response.

As comparison, in the log, a normal push request should be like this

[ codes.vapor.application ] [ TRACE ] Re-using available connection (AsyncKit/ConnectionPool/EventLoopConnectionPool.swift:191)
[ codes.vapor.application ] [ DEBUG ] Send - starting up (APNSwift/APNSwiftConnection.swift:174)
[ codes.vapor.application ] [ INFO ] Send - sending (APNSwift/APNSwiftConnection.swift:204)
[ codes.vapor.application ] [ DEBUG ] Request - building (APNSwift/APNSwiftRequestEncoder.swift:68)
[ codes.vapor.application ] [ TRACE ] Request - built (APNSwift/APNSwiftRequestEncoder.swift:97)
[ codes.vapor.application ] [ TRACE ] Request - sent (APNSwift/APNSwiftRequestEncoder.swift:101)
[ codes.vapor.application ] [ DEBUG ] Response - received (APNSwift/APNSwiftStreamHandler.swift:36)
[ codes.vapor.application ] [ INFO ] Response - successful (APNSwift/APNSwiftStreamHandler.swift:53)
[ codes.vapor.application ] [ TRACE ] Releasing connection (AsyncKit/ConnectionPool/EventLoopConnectionPool.swift:262)

When the issue happens, response doesn’t come, the log is like below

[ codes.vapor.application ] [ TRACE ] Re-using available connection (AsyncKit/ConnectionPool/EventLoopConnectionPool.swift:191)
[ codes.vapor.application ] [ DEBUG ] Send - starting up (APNSwift/APNSwiftConnection.swift:174)
[ codes.vapor.application ] [ INFO ] Send - sending (APNSwift/APNSwiftConnection.swift:204)
[ codes.vapor.application ] [ DEBUG ] Request - building (APNSwift/APNSwiftRequestEncoder.swift:68)
[ codes.vapor.application ] [ TRACE ] Request - built (APNSwift/APNSwiftRequestEncoder.swift:97)
[ codes.vapor.application ] [ TRACE ] Request - sent (APNSwift/APNSwiftRequestEncoder.swift:101)

As vapor/apns use only 1 max connection in configuration to initialize APNSwift, and the connection itself looks active, the connection pool will be completely jammed by the request above, waiting for its response.

So could anyone please enlighten me is there any way I could set a timeout for such case, or did I miss something?

Platform:

  • Ubuntu 18.04
  • Vapor 4.31.0
  • APNS 1.0.0
  • APNSwift 2.1.0

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Hey everyone @xiao99xiao @Dong-Lin.

@jchambers just informed me that Apple has resolved this on their side.

Please let us know if you continue to see anything.