• Client API
  • Android Client SDK SessionManager is null?

Hello,

We use in our Android project to Lightstreamer connection, in the use of LightstreamerClient. Connect, log encountered the following error:


java.lang.NullPointerException: Attempt to write to field 'boolean com.lightstreamer.client.session.Session. switchRequired' on a null object reference in method 'void com.lightstreamer.client.session.SessionManager. changeTransport(boolean, boolean, boolean, boolean, boolean)'
at com.lightstreamer.client.session.SessionManager.changeTransport(SourceFile:49)
at com.lightstreamer.client.LightstreamerEngine.doChangeTransport(SourceFile:85)
at com.lightstreamer.client.LightstreamerEngine.onForcedTransportChanged(SourceFile:5)
at com.lightstreamer.client.LightstreamerClient$InternalListener$3.run(SourceFile:9)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1042)
at com.lightstreamer.util.threads.JoinablePoolExecutor$1$1.run(SourceFile:1)

Has anyone experienced a similar issue? , What could have caused this error?

lightStreamerAndroidClient="4.2.8"

Thank you

Could you attach a complete client log that reproduces the scenario?
For instructions on how to enable logging, refer to this demo.

It was a mistake that happened by chance and I can't reproduce it again. Here is my connection code.

    val client = LightstreamerClient(serverAddress, adapterSet).apply {
        val reconnectionTime = 2000L
        connectionOptions.apply {
            retryDelay = reconnectionTime
            reconnectTimeout = reconnectionTime
            keepaliveInterval = reconnectionTime
            sessionRecoveryTimeout = reconnectionTime
            forcedTransport = "WS"
        }
        connectionDetails.apply {
            user = userConfig
            setPassword(password)
        }
    }
    client.connect()

What causes the SessionManager null?

In theory, the SessionManager should never be null when a client is either connecting or already connected.

If you're using Lightstreamer Server 7.4, the recommended approach is to upgrade to the latest Android Client (version 5.2.2).

    Alessandro.Carioni If the Lightstreamer Server version is 7.2.2, Is it possible to upgrade Android client version from 4.2.8 to 5.2.2? Only the Android Client can be modified.

    Is it only possible to upgrade the Android client version to solve this problem?

    Unfortunately, Client 4.x is out of support and it won't be fixed.
    If you encounter this error frequently, the recommended solution is to upgrade to Client 5.x .
    Please note that this upgrade requires Lightstreamer Server version 7.4.