Scarlet icon indicating copy to clipboard operation
Scarlet copied to clipboard

Linear BackOffStrategy Not Working as Expected

Open rbaid1221 opened this issue 4 years ago • 0 comments

This is how I have set up my connection:

fun initConnection(deviceId: String?) {
        val backoffStrategy = LinearBackoffStrategy(1000)
        val okHttpClient = OkHttpClient.Builder()
            .readTimeout(10, TimeUnit.SECONDS)
            .build()
        val scarletInstance = Scarlet.Builder()
            .webSocketFactory(okHttpClient.newWebSocketFactory("ws://$SERVER_IP:$SERVER_PORT/id=$deviceId&version=${BuildConfig.VERSION_NAME}"))
            .addStreamAdapterFactory(RxJava2StreamAdapterFactory())
            .backoffStrategy(backoffStrategy)
            .build()

        websocketService = scarletInstance.create()
        observerData()
    }

While testing this in practice, it tried reconnecting every second as expected. However, when I saw the logs of one of our customers, I saw this:

05:29:29 | Connection failed 05:29:50 | Connection failed 05:29:51 | Connection failed 05:30:12 | Connection failed

After this point it did not keep trying.

Is there a maxRetry count or something that I am unaware of? I cannot seem to find a retryCount max or a way to set that anywhere.

rbaid1221 avatar Apr 28 '21 20:04 rbaid1221