WCSession fails to sendMessage

Hi

Using Watch OS 3 beta 3 here. My watch app which previously worked with Watch OS 2 seems to be having connectivity issues.


When trying to send a message using


  [[WCSession defaultSession] sendMessage: ...


the error handler returns an error WCErrorDomain code 7014, WCErrorCodeDeliveryFailed.


The message is only attempted to be sent if the session is reachable, which it is at this point. However when I inspect the session object I can see that while reachable is true and the activationState is 2 (WCSessionActivationStateActivated), other properties such as paired and watchAppInstalled are actually false.

I am guessing these conflicting properties are connected to the problem.


Interestingly, when I inspect the session object when it is initially activated from the iOS app, the paired and watchAppInstalled values are true.


I have tried looking into the Watch console logs but there is literally so much going on there it is hard to pinpoint where the issue might be.


Has anyone else encountered this issue with Watch OS 3? Or can anyone point me towards what I should be looking for in the watch's console logs? Thanks.

Replies

I would file a bug report and post the radar number here, so the it can be directed to the necessary devs if its an issue!

I am having a lot of problems with WatchConnectivity in the Watch and iOS simulator.

I can make successful connections for a few seconds at the start of a session, then the logs are filled with a constant stream of:

Watch Extension[10772:415005] [WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterrupted

After this starts, even a new session activation doesnt make it stop.

I have seen similar behavior, but it seems that I onle get the NSXPCConnectionInterrupted if either ios app or watchos app is in the background. It stops when both are in foreground (and can successfully use the session)

Having same issue using watch03 from beta 3. When watch can't get location (works 1/20 tries), [WC] __33 starts quickly streaming. Also happening when sendMessage fails.

i can't help you unfortunately, but just to let people know i'm getting exactly the same.

i just managed to downgrade to beta 2 (can't find it available online, but my time machine thankfully had the archive) and I can confirm that WCSession works as expected without any code changes. So this appears to be a beta 3 regression / bug.

Hey Rohirrim if you could send a bug report and come back here with the radar number so we can follow it ! thanks !!!

radar 27519859 filed. Let's hope for a swift beta 4!

same issue here.. WatchKit Extension[6128:479936] [WC] __33-[WCXPCManager onqueue_reconnect]_block_invoke error reconnecting to daemon due to NSXPCConnectionInterrupted

I have filed radar 27542835. Let's hope this gets looked at before the next beta is released!

For Apple Watch console log. xCode -> Window>Devices , Select the iPhone with a paired Apple Watch , and click triangle button at left bottom of detail view. You will find them.

I'm having similar problems here, even with iOS beta 7 and watchOS beta 6. I see most of these posts are from July—is anyone else still having these issues in the latest betas?

I'm trying to do something like this:


if (session.reachable) {
  NSLog(@"Watch app is reachable");
  [session sendMessage:userInfo replyHandler:nil errorHandler:^(NSError * _Nonnull error) {
  NSLog(@"Error sending message: %@, %@",error,error.userInfo);
  }];
}


And get output like this:


Watch app is reachable
[WC] -[WCSession onqueue_handleMessageCompletionWithError:withMessageID:] BB8C7AAA-E6FE-470D-BF42-1DE48B53C965 due to WCErrorCodeTransferTimedOut->IDSErrorTypeTimedOut->IDSResponseTimedOut
[WC] -[WCSession _onqueue_notifyOfMessageError:withErrorHandler:] errorHandler: YES with WCErrorCodeTransferTimedOut->IDSErrorTypeTimedOut->IDSResponseTimedOut
Error sending message: Error Domain=WCErrorDomain Code=7017 "Transfer timed out." UserInfo={NSLocalizedDescription=Transfer timed out., NSUnderlyingError=0x170449ea0 {Error Domain=com.apple.identityservices.error Code=23 "Timed out" UserInfo={NSLocalizedDescription=Timed out, NSUnderlyingError=0x171a59b30 {Error Domain=com.apple.ids.idssenderrordomain Code=12 "(null)"}}}}, {
    NSLocalizedDescription = "Transfer timed out.";
    NSUnderlyingError = "Error Domain=com.apple.identityservices.error Code=23 \"Timed out\" UserInfo={NSLocalizedDescription=Timed out, NSUnderlyingError=0x171a59b30 {Error Domain=com.apple.ids.idssenderrordomain Code=12 \"(null)\"}}";
}


Even after these errors, session.reachable continues to be true.

Turns out this was mostly my own dumb fault. In my watch app I had only implemented session:didReceiveMessage:, because I was always using a nil replyHandler when I called sendMessage:replyHandler:errorHandler: on the phone. There wasn't any info I needed back, I just wanted to run some code when it finished.


I would have figured this out much sooner if I could get watchOS 3 to give me anything other than kernel logs from a device. Once I tried recreating this problem in the simulator I saw immediately there was an error about a missing method in my WCSessionDelegate.


One thing worth noting is that the documentation on WCSession's reachable property is no longer correct: "On iOS, the value is YES when a paired and active Apple Watch is in range and the associated Watch app is running in the foreground. In all other cases, the value is NO."


From what I can tell reachable will often, if not always, be YES if your app is in the watchOS 3 Dock, or if it has a complication showing on the current watch face.

What happened to radar 27542835? In can't find it on openradar.

I was facing the same issue(Transfer timeedout) frequently when run the Watch OS2 app in Watch OS3 iWatch device even without validating session.reachable flag.