pusher / NWWebSocket

A WebSocket client written in Swift, using the Network framework from Apple.
MIT License
123 stars 25 forks source link

Cannot connect to server on watchOS 9 beta #35

Closed Rexios80 closed 1 year ago

Rexios80 commented 2 years ago

This is most definitely a watchOS issue, but I wanted to make it known and see if anyone here might have some insight into this. The exact same code using NWWebSocket works on watchOS 8, but on watchOS 9 I get:

Socket error: POSIXErrorCode(rawValue: 50): Network is down
Socket error: POSIXErrorCode(rawValue: 50): Network is down

I'm going to create a minimal reproducible example using the raw NWConnection library to see if I can learn anything, but considering how vague this error is I doubt I'll get very far. URLSessionWebSocketTask also broke in watchOS 9. Knowing that websockets are handled by the phone, I'm guessing that the phone part of watch websockets got broken.

benjamin-tang-pusher commented 2 years ago

Can this be reproduced in XCode's watch simulator?

Rexios80 commented 2 years ago

Unfortunately no

benjamin-tang-pusher commented 2 years ago

I don't have a physical Apple watch at hand to reproduce this, I will try to get one and see if I can reproduce it.

benjamin-tang-pusher commented 2 years ago

Could you make a minimal reproduction repo with a watch project? I haven't made one before, and when I add the NWWebsocket package to a watch project, I can't import it into my ContentView. I think it's because it's in an extension. I've used pure NWWebsocket in another iOS project before.

Rexios80 commented 2 years ago

https://github.com/Rexios80/watchos_nwwebsocket_test

Rexios80 commented 2 years ago

Sorry it took so long. I've been busy with a bunch of other things.

paulb777 commented 1 year ago

Also see https://developer.apple.com/forums/thread/714796 for a minimal repro of the watchOS 9 issue.

Rexios80 commented 1 year ago

Also see that linked issue from the Firebase iOS repo. We might just be screwed 🙃

Rexios80 commented 1 year ago

Welp I guess sockets on watchOS are dead

Rexios80 commented 1 year ago

https://developer.apple.com/documentation/technotes/tn3135-low-level-networking-on-watchos

benjamin-tang-pusher commented 1 year ago

Yep, the evidence points to watchOS 9 strictly blocking low level networking.

It also mentions that the simulator doesn't enforce this, which explains why I couldn't reproduce this on the sim.

Rexios80 commented 1 year ago

How do you want to handle this? Just remove watchOS support from the podspec and package manifest?

benjamin-tang-pusher commented 1 year ago

That, and I will modify the readme.

benjamin-tang-pusher commented 1 year ago

I've removed mention of watchOS from the Readme. I'm going to leave it in the other files in the off chance someone is using it in older versions of watchOS.