Backendless Support
 
Answered

Async finding object by objectId not working, load failed

I am trying to find an object by it's objectId.

This code works:

  1. let dataStore = backendless?.data.ofTable("Workouts")

But it throws an exception if the object does not exist.

So I am trying to use this

  1. dataStore?.find(byId: id, response: { (wo) in
  2. print(wo)
  3. workouts.append(Workout.fromDictToWorkout(wDict: wo! as! [String : Any]))
  4. }, error: { (error) in
  5. print(error!)
  6. })

But it just hangs and then returns this:

2017-08-23 16:00:17.885689-0400 PIT[19987:875840] TIC TCP Conn Failed [2:0x604000174580]: 3:-9802 Err(-9802)

2017-08-23 16:00:17.886198-0400 PIT[19987:875840] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

2017-08-23 16:00:17.886375-0400 PIT[19987:875840] Task <882E0447-F399-40B1-975E-B160F5934638>.<0> HTTP load failed (error code: -1200 [3:-9802])

2017-08-23 16:00:17.886622-0400 PIT[19987:875842] NSURLConnection finished with error - code -1200

What is going on here? Is there a way to just handle the exception that the sync method throws? Why isn't the async one working?

Leave a Comment

Comments (7)

photo
1

Hello,

You can catch errors from blocking/synchronous API calls using try/catch as shown in the documentation:

https://backendless.com/docs/ios/doc.html#shared_error_handling

As for the http-related error, are you using our Cloud service or perhaps a private installation of Backendless?

Regards,

Mark

photo
1

Hi,

That try/ catch worked perfectly! Thank you so much for your speedy help.

And as for the http-related error, I am using your Cloud service.

photo
1

It is still quite odd that you're getting that error for the async call. The underlying networking mechanism in our library is the same between sync and async.

photo
1

I just tried it again for fun and got the same thing:

  1. dataStore?.find(byId: ids, response: { (wo) in
  2. print(wo!)
  3. }, error: { (error) in
  4. print(error!)
  5. })

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

2017-08-23 16:46:45.451477-0400 PIT[20654:917222] Task <3B5AC8FF-CF21-4F1B-9712-CB9CCE541B52>.<0> HTTP load failed (error code: -1200 [3:-9802])

2017-08-23 16:46:45.451670-0400 PIT[20654:916812] NSURLConnection finished with error - code -1200

I am running Xcode 9 beta 6 if that means anything to you.

photo
1

Sorry, I had a typo, I meant this

  1. for id in ids {
  2. dataStore?.find(byId: id, response: { (wo) in
  3. print(wo!)
  4. }, error: { (error) in
  5. print(error!)
  6. })
  7. }

2017-08-23 16:50:01.511139-0400 PIT[20770:919422] TIC TCP Conn Failed [2:0x60c00016b1c0]: 3:-9802 Err(-9802)

2017-08-23 16:50:01.511801-0400 PIT[20770:919422] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

2017-08-23 16:50:01.511934-0400 PIT[20770:919422] Task <2F2B33A6-0ADD-4676-B859-E602DCA2BDB6>.<0> HTTP load failed (error code: -1200 [3:-9802])

2017-08-23 16:50:01.512112-0400 PIT[20770:919424] NSURLConnection finished with error - code -1200

photo
1

Does it happen in the project you download and run by following the instructions from here: ?https://backendless.com/docs/ios/doc.html#quick_start_guide

photo
1

Yes, that worked. I even tried shifting and tweaking things to be more like the way I have it and it still worked every time.

Very strange