Build a mobile chat app with persistent server connections that reconnect automatically on flaky networks.
Add high-performance async logging with automatic compression and log-directory cleanup to an iOS or Android app.
Detect network connection failures in a mobile app and surface helpful diagnostics to the user.
Replace a custom networking stack with WeChat's battle-tested STN connection manager for push-style messaging.
iOS, macOS, and Windows builds require Python 3.10+ and platform-specific toolchains, Android is simpler via Gradle.
Mars is a cross-platform networking and logging component built by the WeChat mobile team at Tencent. WeChat handles billions of users, and Mars is the low-level plumbing it relies on to send small messages between phones and servers reliably while using as little battery and mobile data as possible. The project open-sources that plumbing so other apps can adopt the same approach instead of writing their own stack. Mars has four pieces. comm is a shared library of utilities such as sockets, threads, message queues, and coroutines. Xlog is a high-performance, reliable log component that writes log files asynchronously, compresses them with zlib, and automatically cleans up its log directory. SDT is a network-detection component that helps diagnose why a connection failed. STN, the largest part, is the signalling network component: it manages long-lived connections to a server (a long-link) for push-style messaging and short-link requests for one-shot calls, handles reconnection, and adapts to a mobile app's lifecycle, including background/foreground transitions and network changes. You would use Mars when building a mobile app that needs a small but reliable conversation with a backend (chat messages, signals, presence) and you care about battery and data usage on flaky mobile networks. It is suitable for small-volume data transmission, not large file transfer. The codebase is written in C++ and builds on iOS, OS X, Android, and Windows. Android integration is offered as a Gradle dependency (mars-wrapper for a quick start, mars-core or standalone mars-xlog for production), while iOS, OS X, and Windows builds use Python build scripts requiring Python 3.10 or higher.
← tencent on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.