Skip to content

Java Client NPE crash when calling stop before connected #28608

@dsuresh-ap

Description

@dsuresh-ap

Describe the bug

If you call close() on a connection that did not establish yet (in the CONNECTING state) a NPE will be thrown due to the code calling transport.stop() on a null reference.

See HubConnection.stop(String errorMessage)

Completable stop = transport.stop();

To Reproduce

  1. Call .start() on a connection.
  2. Before the connection changes to the connected state (or successfully has a transport) call .close() on it. This happened to us because our server returns us 404 when attempting to connect with long polling so we .close() on it to stop it before switching to SSE.

Exceptions (if any)co

2020-12-11 16:48:49.094 15652-15652/x E/AndroidRuntime: FATAL EXCEPTION: main
    Process:x, PID: 15652
    java.lang.NullPointerException: Attempt to invoke interface method 'io.reactivex.Completable com.microsoft.signalr.Transport.stop()' on a null object reference
        at com.microsoft.signalr.HubConnection.stop(HubConnection.java:424)
        at com.microsoft.signalr.HubConnection.stop(HubConnection.java:513)
        at x.websockets.connection.core.SignalRCoreWebsocketConnection.disconnect(SignalRCoreWebsocketConnection.kt:185)
        at x.websockets.connection.core.OrchestratorCoreWebsocketConnection.disconnect(OrchestratorCoreWebsocketConnection.kt:65)
        at x.websocket.WebsocketManager.disconnectAllConnections(WebsocketManager.kt:116)
        at x.app.DebugMenuCreatorKt$createDebugMenuListener$1$onForceWebsocketTransportMenuRequested$1.onClick(DebugMenuCreator.kt:95)
        at androidx.appcompat.app.AlertController$AlertParams$3.onItemClick(AlertController.java:1068)
        at android.widget.AdapterView.performItemClick(AdapterView.java:374)
        at android.widget.AbsListView.performItemClick(AbsListView.java:1736)
        at android.widget.AbsListView$PerformClick.run(AbsListView.java:4207)
        at android.widget.AbsListView$7.run(AbsListView.java:6692)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Further technical details

  • ASP.NET Core version 5.0.1
  • The IDE (VS / VS Code/ VS4Mac) Android Studio 4.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and serversbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions