简体   繁体   English

为什么红蜘蛛不再在真正的 Apple Watch (WatchOS 6) 上运行?

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

Recently I upgraded my Apple Watch to WatchOS 6.0.1, my iPhone to iOS 13.1.2, Xcode to 11.1.最近我将我的 Apple Watch 升级到 WatchOS 6.0.1,我的 iPhone 升级到 iOS 13.1.2,Xcode 到 11.1。 MacOS still 10.14.6. MacOS 仍然是 10.14.6。

I've created an Independent Apple Watch project where I test the communication between the Watch and a WebSocket server using Starscream: https://github.com/daltoniam/Starscream我创建了一个独立的 Apple Watch 项目,在其中我使用 Starscream 测试 Watch 和 WebSocket 服务器之间的通信: https://github.com/daltoniam/Starscream

It works perfectly on the Simulator but on real Apple Watch when I try to connect to the server I got these errors :在模拟器上完美运行,但在真正的 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")

I'll show you the code of my app:我将向您展示我的应用程序的代码:

InterfaceController.swift接口控制器.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")
}

} }

I tried using Starscream with iOS 13.1.2 and it works perfectly both on Simulator and real iPhone .我尝试将StarscreamiOS 13.1.2一起使用,它在 Simulator 和 real iPhone 上都能完美运行

Is this a bug of WatchOS 6 or is Starscream that needs an upgrade?这是 WatchOS 6 的错误还是红蜘蛛需要升级?

Thanks in advance: :)提前致谢: :)


EDIT: 5th November 2019编辑: 2019 年 11 月 5 日

I've updated my Apple Watch to WatchOS 6.1 and iPhone to iOS 13.2 and WebSocket still doesn't work on the watch...我已将我的 Apple Watch 更新为 WatchOS 6.1,将 iPhone 更新为 iOS 13.2,WebSocket 仍然无法在手表上运行...

Got some new errors though:虽然有一些新错误:

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