Would rather not post the URL publicly, can I email it to you at the
address in your post?
Absolutely. I put that URL into a test project and it seems to connect just fine. Specifically, this code:
Code Block | class MainViewController: UITableViewController { |
|
| var connection: NWConnection? |
| |
| func test() { |
| if let connection = self.connection { |
| connection.cancel() |
| self.connection = nil |
| } |
| let params = NWParameters.tls |
| let webSocketOptions = NWProtocolWebSocket.Options() |
| params.defaultProtocolStack.applicationProtocols.insert(webSocketOptions, at: 0) |
| let url = URL(string: "wss://example.com:443")! |
| let connection = NWConnection(to: .url(url), using: params) |
| connection.stateUpdateHandler = { state in |
| print(state) |
| } |
| connection.start(queue: .main) |
| } |
| |
| … rest of the view controller … |
| } |
prints:
Code Block | preparing |
| ready |
indicating that the TCP + TLS + WebSocket connection went through.
IMPORTANT In the code posted here I’m using
example.com but in my test project I used the URL you sent me.
This suggests one of two problems:
To make progress I’d like you to create a small test app with the code above. Does it reproduce the problem? That’ll tell us whether this is an environmental issue or a code difference.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"