Ensure the network streams are disconnected before CBLWebSocket is dealloc

Description

In CBLWebSocket, c4socket will call the registered dispose() function before being freed. The current implementation in CBLWebSocket assumes that the c4socket will CBLWebSocket to close the connection to disconnect from the remote server (closing network streams, socket, and DNS Service if being used) before calling the dispose() function.

However, from the CBSE ticket, it's possible the dispose() function could be called before the closing connection is actually. One of the reasons could be a delay that happened during the closing connection process. If the close process is timeout, c4socket will call the dispose() function right away.

As we couldn't have logs from the customer when the issue happened, I couldn't know for sure about the root cause of the issue. For example, there could be a case that c4socket didn't call to close the connection before calling the dispose() function at all (I couldn't see how this could happen from reviewing the code). The fix for this issue will ensure that the network streams and other opened network components will be closed before the CBLWebSocket is dealloc.

Activity

Show:

CB robot February 28, 2024 at 4:38 PM

Build couchbase-lite-ios-3.2.0-73 contains couchbase-lite-ios commit 2285757 with commit message:
: Ensure to disconnect from the remote before CBLWebSocket being dealloc (#3240)

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Sprint

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created February 23, 2024 at 7:25 PM
Updated October 4, 2024 at 2:06 PM
Resolved March 1, 2024 at 9:21 PM
Instabug