Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to secure wss:// websocket on iOS 11 & earlier #748

Closed
nickdowell opened this issue Mar 11, 2020 · 1 comment · Fixed by #749
Closed

Cannot connect to secure wss:// websocket on iOS 11 & earlier #748

nickdowell opened this issue Mar 11, 2020 · 1 comment · Fixed by #749

Comments

@nickdowell
Copy link
Contributor

The FoundationTransport (used on iOS 11 & earlier) does not establish a secure connection to the host, resulting in a failed connection to hosts that require security.

The following code snippet replicates the problem on all platforms by forcing use of the FoundationTransport

import Starscream

class WebsocketTester: WebSocketDelegate {
    
    var webSocket: WebSocket?
    
    func start() {
        let url = URL(string: "wss://echo.websocket.org")!
        webSocket = WebSocket(request: URLRequest(url: url), engine:
            WSEngine(transport: FoundationTransport(), certPinner: FoundationSecurity()))
        webSocket?.delegate = self
        webSocket?.connect()
    }
    
    func didReceive(event: WebSocketEvent, client: WebSocket) {
        print(#function, event)
    }
}

The output of running this is

didReceive(event:client:) cancelled

This has previously been reported in #728

@jaltreuter
Copy link

@nickdowell thank you for putting up that pull request. This same issue started happening in my app after upgrading from Starscream 3.0.5 to 4.0.0. I ended up simply making a copy of FoundationTransport and adding your changes, and that was effective at solving the problem.

I'd love to see this get some attention from the devs, since it's easily reproducible and affects a reasonably large audience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants