Errors that can occur with `NEProviderTunnelSession.sendProviderMessage`

The documentation for NEProviderTunnelSession.sendProviderMessage says the following:

If this method can’t start sending the message it reports an error in the returnError parameter. If an error occurs while sending the message or returning the result, nil should be sent to the response handler as notification.

My question is, what sorts of errors can occur that would result in this function calling the completion handler with a nil value? When I'm returning an error explicitly to the client from my network extension, I call back with a specific piece of data that indicates an error condition (beginning with the byte 255.) However, I still occasionally get a callback with a nil value, which results in the app sometimes getting confused. I don't notice anything wrong from the extension's side when I check its logs.

What issue in the message sending layer might be causing this? Is there a process whose logs I can monitor that might shine some light on the problem and show me what problem I need to avoid?

Answered by DTS Engineer in 715025022

This is built on top of XPC so there’s a whole bunch of errors that could cause this. You wrote:

I don't notice anything wrong from the extension's side when I check its logs.

Right. Because the failure indicates that the system wasn’t able to pass the message to the extension.

Is there a process whose logs I can monitor that might shine some light on the problem

There’s probably some entry in the system log that offer some insight into this. See Your Friend the System Log for more background on that. What I’d do in this case is add your own log entry when you get this error and then trace back looking for relevant XPC or NE log entries.

and show me what problem I need to avoid?

I wouldn’t approach this as something you can avoid, but rather something you have to deal with. This is a pretty simple API, so it’s hard to ‘hold it wrong’. It’s likely that this is a transient that you just have to deal with.

Share and Enjoy

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

Accepted Answer

This is built on top of XPC so there’s a whole bunch of errors that could cause this. You wrote:

I don't notice anything wrong from the extension's side when I check its logs.

Right. Because the failure indicates that the system wasn’t able to pass the message to the extension.

Is there a process whose logs I can monitor that might shine some light on the problem

There’s probably some entry in the system log that offer some insight into this. See Your Friend the System Log for more background on that. What I’d do in this case is add your own log entry when you get this error and then trace back looking for relevant XPC or NE log entries.

and show me what problem I need to avoid?

I wouldn’t approach this as something you can avoid, but rather something you have to deal with. This is a pretty simple API, so it’s hard to ‘hold it wrong’. It’s likely that this is a transient that you just have to deal with.

Share and Enjoy

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

Errors that can occur with `NEProviderTunnelSession.sendProviderMessage`
 
 
Q