Websocket client for Centrifugo server and Centrifuge library.
There is no v1 release of this library yet – API still evolves. At the moment patch version updates only contain backwards compatible changes, minor version updates can have backwards incompatible API changes.
Check out client SDK API specification to learn how this SDK behaves. It's recommended to read that before starting to work with this SDK as the spec covers common SDK behavior - describes client and subscription state transitions, main options and methods. Also check out examples folder.
The features implemented by this SDK can be found in SDK feature matrix.
centrifuge-javais compatible only with the latest Centrifugo server (v4) and Centrifuge >= 0.25.0. For Centrifugo v2, Centrifugo v3 and Centrifuge < 0.25.0 you should use
Library available in Maven: https://search.maven.org/artifact/io.github.centrifugal/centrifuge-java
Obfuscation with ProGuard
Centrifuge-java library uses Protobuf library (Lite version) for client protocol. This fact and the fact that Protobuf Lite uses reflection internally can cause connection errors when releasing your application with Android shrinking and obfuscation features enabled. See protocolbuffers/protobuf#6463 for details. To deal with this centrifuge-java comes with Proguard rules included in the jar.
More information about Android shrinking.
See example code in console Java example or in demo Android app
To use with Android don't forget to set INTERNET permission to
<uses-permission android:name="android.permission.INTERNET" />
Usage in background
When a mobile application goes to the background there are OS-specific limitations for established persistent connections - which can be silently closed shortly. Thus in most cases you need to disconnect from a server when app moves to the background and connect again when app goes to the foreground.
Library is available under the MIT license. See LICENSE for details.
This section contains an information for library contributors. You don't need generating protobuf code if you just want to use
centrifuge-java in your project.
The protobuf definitions are located in
Protocol class is generated automatically during project compilation by
protobuf gradle plugin.
Check API signatures
We use metalava-gradle to ensure we are aware of breaking API changes in the library.
All PRs check API signatures for compatibility. If you see an error, it may indicate there is a breaking change.
Regenerate API signature with the following command and include an updated
api.txt in your PR:
Also indicate a breaking change in changelog.
To verify API compatibility locally, run the following command:
- Bump version in
- Update changelog to reflect API and behavior changes, bugfixes.
- Create new library tag.
The release GitHub Action should now publish the library.
Do all steps from the automatic publishing. Create configuration file
signing.keyId=<LAST_8_SYMBOLS_OF_KEY_ID> signing.password=<PASSWORD> signing.secretKeyRingFile=/Path/to/.gnupg/secring.gpg mavenCentralUsername=<USERNAME> mavenCentralPassword=<PASSWORD>
./gradlew publish --no-daemon --no-parallel ./gradlew closeAndReleaseRepository
The second command will promote staged release to production on MavenCentral.
You can do it manually by following the instructions:
- Login here: https://oss.sonatype.org/
- Go to
- Find release, push
- Thanks to Maks Atygaev for initial library boilerplate