Industry Best Practices & Top Insights delivered to your Inbox.
Blog Engineering

A mock server for APNS in Go

Jude Pereira Principal Architect at CleverTap, working on TesseractDB™. He also contributes to the engineering culture, improving developer productivity.

We’ve recently migrated to the new HTTP/2 API to send out push notifications to iOS devices, for greater throughput and reliability (as compared to the binary protocol).
As such, to stress test our system, we needed a mock HTTP/2 APNS server. Instinctively, we explored various ways to build one in Java, which is what most of our core system is written in. However, at this time, HTTP/2 support in Java seems to be very weak, with just a client available from the Jetty project.
Next up was Python, using the Hyper library. We wrote one inspired from the asyncio library example found here. For some reason, Jetty’s HTTP/2 transport library couldn’t play nicely with the Python server, however, the Chrome browser could. We didn’t have the time to investigate what was going on, and then we moved to Go.
Finally, using Go’s HTTP/2 library, we had our home-grown mock APNS server! For those of you who’d like to use it, we’ve hosted the code to it here, on GitHub.

Posted on February 17, 2016