Skip to content

WebSocket Cannot Reconnect When isConnecting Stays true Forever #1052

@yoheimuta

Description

@yoheimuta

Describe the Bug

After Fix connection race when using WSEngine was merged, the isConnecting property was introduced to prevent multiple connection attempts. However, as reported in this comment, isConnecting sometimes remains true, which prevents users from reconnecting indefinitely.

Steps to Reproduce

  1. Call connect()
  2. Put the device into sleep mode so that the WebSocket connection closes.
  3. The server goes down while the device is asleep.
  4. Call connect() again to attempt a reconnection.
  5. The server is back online.
  6. The isConnecting flag remains true, preventing connect() from proceeding.

Expected Behavior

  • The WebSocket can reconnect when the server is back online.
  • The isConnecting flag should be reset to false once a previous connection attempt fails, allowing new connections.

Environment

  • OS/Version: iOS 18.3.1
  • Starscream Version: 4.0.6 and later
  • Xcode Version: 16.0

Additional Context

  • This issue is caused by isConnecting staying true after a failed connection attempt.
  • A potential fix might involve resetting isConnecting when a connection is explicitly closed or when an error occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions