Skip to content

Leaked connections when trying to connect to a high latency server #7

Description

@jlcvp

This following snippet of code in the project is creating multiple connections when connecting to high latency servers. The while loop calls self.client?.connect again (thus, creating another websocketclient) if the first call takes more than 200 + self._checksDelay millis to connect/fail

if !self.isConnected() {
self.client?.disconnect()
usleep(200_000)
self.client?.connect()
usleep(self._checksDelay)
self.updateLastPoint()
continue
}

The problem with this busy wait approach is that we don't have a way outside this library code to manage those connections and terminate the duplicates if needed.

I think we Should try to use a Lock before the if !self.isConnected() { check to do this verification only after the connection handshake itself. That way we would have only 2 states possible (connection successful or connection failed), hence avoiding the duplicates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions