簡體   English   中英

為什么紅蜘蛛不再在真正的 Apple Watch (WatchOS 6) 上運行?

[英]Why is Starscream not working anymore on real Apple Watch (WatchOS 6)?

最近我將我的 Apple Watch 升級到 WatchOS 6.0.1,我的 iPhone 升級到 iOS 13.1.2,Xcode 到 11.1。 MacOS 仍然是 10.14.6。

我創建了一個獨立的 Apple Watch 項目,在其中我使用 Starscream 測試 Watch 和 WebSocket 服務器之間的通信: https://github.com/daltoniam/Starscream

在模擬器上完美運行,但在真正的 Apple Watch上,當我嘗試連接到服務器時出現以下錯誤

2019-10-08 18:57:53.064887+0200 BackgroundWebSocketOnlyWatch WatchKit Extension[251:31011] [] nw_connection_get_connected_socket [C1] Client called nw_connection_get_connected_socket on unconnected nw_connection

2019-10-08 18:57:53.068928+0200 BackgroundWebSocketOnlyWatch WatchKit Extension[251:31011] TCP Conn 0x16d8d5f0 Failed : error 0:50 [50]

websocket is disconnected: Optional("The operation couldn’t be completed. Network is down")

我將向您展示我的應用程序的代碼:

接口控制器.swift

import WatchKit
import Foundation
import Starscream

class InterfaceController: WKInterfaceController, WebSocketDelegate {

let socket = WebSocket(url: URL(string: "ws://echo.websocket.org/")!)

@IBOutlet var label: WKInterfaceLabel!

/**************************************************************************************************/

override func awake(withContext context: Any?) {
    super.awake(withContext: context)

    socket.delegate = self
}

override func willActivate() {
    // This method is called when watch view controller is about to be visible to user
    super.willActivate()
}

override func didDeactivate() {
    // This method is called when watch view controller is no longer visible
    super.didDeactivate()
}

/************************************************************************************************/

@IBAction func connectButtonPressed() {

    socket.connect()
}

@IBAction func sendButtonPressed() {

    socket.write(string: "Hi!")
}

@IBAction func disconnectButtonPressed() {

    socket.disconnect()
}

/******************************************************************************************/

func websocketDidConnect(socket: WebSocketClient) {
    print("websocket is connected")
    label.setText("Connected")
}
func websocketDidDisconnect(socket: WebSocketClient, error: Error?) {
    print("websocket is disconnected: \(error?.localizedDescription)")
    label.setText("Disconnected")
}
func websocketDidReceiveMessage(socket: WebSocketClient, text: String) {
    print("got some text: \(text)")
    label.setText("Received: \(text)")
    createVibration()

}
func websocketDidReceiveData(socket: WebSocketClient, data: Data) {
    print("got some data: \(data.count)")
}
/******************************************************************************************/

// Creates vibration
func createVibration() {

    WKInterfaceDevice.current().play(.notification)
    print("Vibration created")
}

}

我嘗試將StarscreamiOS 13.1.2一起使用,它在 Simulator 和 real iPhone 上都能完美運行

這是 WatchOS 6 的錯誤還是紅蜘蛛需要升級?

提前致謝: :)


編輯: 2019 年 11 月 5 日

我已將我的 Apple Watch 更新為 WatchOS 6.1,將 iPhone 更新為 iOS 13.2,WebSocket 仍然無法在手表上運行...

雖然有一些新錯誤:

2019-11-05 12:33:29.317757+0100 BackgroundWebSocketBothDevices WatchKit Extension[269:37201] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:4 Err:-1 Errno:1 Operation not permitted

2019-11-05 12:33:29.317919+0100 BackgroundWebSocketBothDevices WatchKit Extension[269:37201] [] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)

2019-11-05 12:33:29.319083+0100 BackgroundWebSocketBothDevices WatchKit Extension[269:37255] [] nw_connection_get_connected_socket [C1] Client called nw_connection_get_connected_socket on unconnected nw_connection

2019-11-05 12:33:29.319150+0100 BackgroundWebSocketBothDevices WatchKit Extension[269:37255] TCP Conn 0x155a7360 Failed : error 0:-65563 [-65563]

websocket is disconnected: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -72000.)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM