Last active
September 16, 2022 14:12
-
-
Save ryanwilson/fd5454a681eab32348ebc7119949182c to your computer and use it in GitHub Desktop.
watchOS 9 on device websocket failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2022 Google LLC | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
Text("Websockets are broken in watchOS 9") | |
.task { | |
let url = URL(string: "wss://ws.postman-echo.com/raw")! | |
let task = URLSession.shared.webSocketTask(with: url) | |
task.resume() // Needed before the async send/receive calls. | |
// Send. This works on the watchOS simulator but fails on real devices running watchOS 9. | |
do { | |
// This logs `NSPOSIXErrorDomain` code `19` ("Operation not supported by device") on a real device | |
// running watchOS 9. | |
try await task.send(.string("echo")) | |
print("Message send successful") | |
} catch { | |
// This returns `NSURLErrorDomain` code `-1009` "The Internet connection appears to be offline" | |
// on a real device running watchOS 9. | |
print("Error sending: \(error)") | |
return | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2022-09-16 09:41:54.409680-0400 watchOS9Websockets Watch App[968:637619] Connection 1: received failure notification | |
2022-09-16 09:41:54.410650-0400 watchOS9Websockets Watch App[968:637619] Connection 1: failed to connect 1:50, reason -1 | |
2022-09-16 09:41:54.410679-0400 watchOS9Websockets Watch App[968:637619] Connection 1: encountered error(1:50) | |
2022-09-16 09:41:54.432645-0400 watchOS9Websockets Watch App[968:637613] Error getting network data status Error Domain=NSPOSIXErrorDomain Code=19 "Operation not supported by device" | |
2022-09-16 09:41:54.432850-0400 watchOS9Websockets Watch App[968:637613] Task <7AA472C9-8847-4D10-B15D-EA7C970BE6F0>.<1> HTTP load failed, 0/0 bytes (error code: -1009 [1:50]) | |
2022-09-16 09:41:54.445194-0400 watchOS9Websockets Watch App[968:637619] Task <7AA472C9-8847-4D10-B15D-EA7C970BE6F0>.<1> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLStringKey=https://ws.postman-echo.com/raw, NSErrorFailingURLKey=https://ws.postman-echo.com/raw, NSLocalizedDescription=The Internet connection appears to be offline., _NSURLErrorRelatedURLSessionTaskErrorKey=( | |
"LocalWebSocketTask <7AA472C9-8847-4D10-B15D-EA7C970BE6F0>.<1>" | |
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <7AA472C9-8847-4D10-B15D-EA7C970BE6F0>.<1>} | |
Error sending: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSErrorFailingURLKey=https://ws.postman-echo.com/raw, NSErrorFailingURLStringKey=https://ws.postman-echo.com/raw, NSLocalizedDescription=The Internet connection appears to be offline.} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment