Scarlet is a Retrofit-inspired WebSocket client for Kotlin, Java, and Android.
Scarlet addresses the complexity of managing WebSocket connections by providing a declarative interface pattern familiar to developers who use Retrofit. You define a WebSocket client as a Kotlin or Java interface with annotated methods, then Scarlet generates an implementation that handles connection lifecycle, message serialization, and stream adaptation. The tool is driven by a state machine on Android, managing connection state transitions automatically.
Scarlet suits projects that need real-time bidirectional communication over WebSocket and want to avoid boilerplate connection management code. It works well for Android applications, backend services in Kotlin or Java, and scenarios requiring reactive streams. The tool integrates with popular serialization libraries including Moshi, Gson, Protocol Buffers, and Jackson, and supports reactive adapters for RxJava and Kotlin Coroutines. It can use OkHttpClient as the underlying WebSocket factory or MockHttpServer for testing.
The project is actively evolving beyond WebSocket support. Development is underway on a new version that extends the framework to handle other persistent connection protocols including ServerSentEvent, Socket IO, STOMP, and MQTT, available on a separate branch. This expansion indicates the maintainers are building toward a more general-purpose persistent connection client rather than remaining WebSocket-specific.