Backendless Support
 
Answered

v4 Pub/Sub Messaging Question

Hi all,

I thought i'd give pub/sub messaging a try in my iOS app, so I followed the guide from your blog here:

https://backendless.com/feature-65-basic-publishsubscribe-messaging/

Following the guide, I subscribe to "testchan" as follows:

  1. backendless?.messaging.subscribe("testchan", subscriptionResponse: { (msgs) in
  2. for msg in msgs! {
  3. print("Received message - \(msg.data)")
  4. }
  5. }, subscriptionError: { (fault) in
  6. print("fault on sub get: \(fault)")
  7. }, response: { (subscription) in
  8. print("subscribed \(subscription?.channelName)")
  9. }, error: { (fault) in
  10. print("fault on subscription signup \(fault)")
  11. })

When running the app, it takes forever to load on the loading screen, and does not continue until the request times out (which is odd, because this is the async function, no?)

Eventually, the app loads after it times out as follows:

  1. fault on subscription signup Optional(FAULT = '-1200' [NSURLErrorDomain] <An SSL error has occurred and a secure connection to the server cannot be made.> )

I also just updated to the latest iOS SDK from github to see if it would help, but it does not. (v.4.0.14)

Am I missing something in this process, or is this a bug?

Renato

Leave a Comment

Comments (7)

photo
1

Hello Renato,

please check this doc. It contains all the description, signatures and examples of pub/sub for v4.

Regards, Olga

photo
1

Hi Olga,

I double checked the signature of the code block, as you pointed out with the above doc, and the issue still persists.

I'm now using the 4.0.15 version of the SDK via cocoapods, and its still cites the SSL error.

  1. Optional(FAULT = '-1200' [NSURLErrorDomain] <An SSL error has occurred and a secure connection to the server cannot be made.> )

Renato

photo
1

Hello,

Do you have the "Allow Arbitrary Loads" of "App Transport Security" set to YES in your Info.plist file?

If "Allow Arbitrary Loads" = YES and the error still occurs, please share with us the simple project which reproduce this issue so we could check it.

Regards, Olga

photo
1

Hi Olga,

Correct - I have Arbitrary loads set to YES under ATS for my project.

After updating my project to Swift 4 today, I now see new context that might help:

  1. [BoringSSL] Function nw_protocol_boringssl_input_finished: line 1389 Peer disconnected during the middle of a handshake. Sending errSSLFatalAlert(-9802) alert
  2. TIC TCP Conn Failed [1:0x1c4162f40]: 3:-9802 Err(-9802)
  3. NSURLConnection finished with error - code -1001
  4. TIC TCP Conn Failed [2:0x1c0163d80]: 3:-9802 Err(-9802)
  5. TIC TCP Conn Failed [3:0x1c0163900]: 3:-9802 Err(-9802)
  6. NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)
  7. Task <8F276DB6-C20F-44EB-9F57-A7A1D85AECC0>.<0> HTTP load failed (error code: -1200 [3:-9802])
  8. NSURLConnection finished with error - code -1200

Just for debugging purposes, I set Allow Arbitrary Loads = NO temporarily, just to see if it would work, but the same result persists.

Did you still want me to see if I can replicate this in a demo project?

Renato

photo
1

It looks like it has something to do with the SSL handshake failure between your device and our servers. The root cause might be somewhere in the SSL setup on your device. Do you have any other devices you could test it from?

Btw, if the endpoint is set (via API) to http://api.backendless.com, the problem will go away.

Regards,

Mark

photo
1

Hmm, I set Arbitrary loads = NO and then added exception domains to satisfy my previous requirements, and it seems to not hang now. (It also seems to be related to ios 11).

I also seem to be getting a backendless error code (5008) now, which is a good sign & I think its safe to close this.

Thanks for pointing me in the right direction :)

R

photo
1

Ohh, and also just FYI, I had to explicitly enforce that the backendless subscribe function be called on the main thread for it to not hang :)

photo