Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Do watchOS apps support IP request communication within a local area network?

As a third-party application on Apple Watch, can it be located in the same LAN httpServer? Currently, when testing to initiate an http request in the LAN, the connection timeout is returned, code: -1001

self.customSession.request("http://10.15.48.191:9000/hello").response { response in
                        switch response.result {
                        case .success(let data):
                            dlog("✅ 请求成功,收到数据:")
                            if let html = String(data: data ?? Data(), encoding: .utf8) {
                                dlog(html)
                            }
                            
                        case .failure(let error):
                            dlog("❌ 请求失败:\(error.localizedDescription)")
                        }
                    }

执行后报错

Task <B71BE820-FD0E-4880-A6DD-1F8F6EAF98B0>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "请求超时。" UserInfo={_kCFStreamErrorCodeKey=-2102, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <B71BE820-FD0E-4880-A6DD-1F8F6EAF98B0>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <B71BE820-FD0E-4880-A6DD-1F8F6EAF98B0>.<1>",
    "LocalDataPDTask <B71BE820-FD0E-4880-A6DD-1F8F6EAF98B0>.<1>",
    "LocalDataTask <B71BE820-FD0E-4880-A6DD-1F8F6EAF98B0>.<1>"
), NSLocalizedDescription=请求超时。, _kCFStreamErrorDomainKey=4, NSErrorFailingURLStringKey=http://10.15.48.191:9000/hello, NSErrorFailingURLKey=http://10.15.48.191:9000/hello}

Answered by DTS Engineer in 841142022

This won’t work by default. While you’re using a high-level API, URLSession, getting this to work would require low-level network access, which isn’t the standard on watchOS.

I suspect it will work if you gain low-level access, as explained in TN3135 Low-level networking on watchOS.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This won’t work by default. While you’re using a high-level API, URLSession, getting this to work would require low-level network access, which isn’t the standard on watchOS.

I suspect it will work if you gain low-level access, as explained in TN3135 Low-level networking on watchOS.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Do watchOS apps support IP request communication within a local area network?
 
 
Q