readDataWithCompletionHandler on flow not returning

Once I have the flow received in handleNewFlow I
  • call openWithLocalEndpoint

  • create a thread in which I read through the local endpoint flow and send the data to server

  • return YES so to handle the flow .

but readDataWithCompletionHandler is not returning neither success nor failure .

I have passed the flow to the thread properly . is it like the flow has become invalid since my reads are on a separate thread ?

should I have to call any API to keep the flow alive ?
Answered by DTS Engineer in 627907022
Most folks creating NetworkExtension providers are either use Swift or Objective-C with ARC. In those scenarios you don’t need to, indeed can’t, call -retain explicitly. Rather, you’re expected to maintain a strong reference to the flow while you’re using it.

How you do this depends on the structure of your code. It’s common for folks to have an object that tracks the state of a flow and, if you do that, you should store the flow in a strong property on that object and then, in your provider, maintain a reference to all of those objects in a dictionary, array or set.

If you are using Objective-C with manual retain/release then you may need to manually call -retain but in most cases that’s not necessary because of the approach I described in the previous paragraph.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
What if you tried opening the remote side of the connection first, let it go into the ready state, and then you tried opening the flow with the local endpoint? Does this help the situation out any? From there reading from the remote side and writing to the flow. Likewise reading from the flow and writing to the remote side.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
thanks Matt for the suggestion. will try that .
  • the documentation also says "If the App Proxy Provider decides to proxy the flow, it should create a reference to the flow in its data structures." doe this "reference "means "retain" ?

  • if yes, does this suggested design retain the flow or we have to manually call retain method on the flow ?


it appears that calling retain is a mandatory step . without calling retain it does not work .
@matt : please can you confirm .

jeev
Accepted Answer
Most folks creating NetworkExtension providers are either use Swift or Objective-C with ARC. In those scenarios you don’t need to, indeed can’t, call -retain explicitly. Rather, you’re expected to maintain a strong reference to the flow while you’re using it.

How you do this depends on the structure of your code. It’s common for folks to have an object that tracks the state of a flow and, if you do that, you should store the flow in a strong property on that object and then, in your provider, maintain a reference to all of those objects in a dictionary, array or set.

If you are using Objective-C with manual retain/release then you may need to manually call -retain but in most cases that’s not necessary because of the approach I described in the previous paragraph.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
okay thank you . these are good pointers .
readDataWithCompletionHandler on flow not returning
 
 
Q