Support Topics Documentation Slack YouTube Blog

v4 Pub/Sub Messaging Question

(Renato N) #1

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:

Following the guide, I subscribe to “testchan” as follows:

backendless?.messaging.subscribe("testchan", subscriptionResponse: { (msgs) in
            for msg in msgs! {
                print("Received message - \(")
        }, subscriptionError: { (fault) in
            print("fault on sub get: \(fault)")
        }, response: { (subscription) in
            print("subscribed \(subscription?.channelName)")
        }, error: { (fault) in
            print("fault on subscription signup \(fault)")

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:

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?


(Olha Danylova) #2

Hello Renato,

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

Regards, Olga

(Renato N) #3

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.

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


(Olha Danylova) #4


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

Screen Shot 2017-09-27 at 11.01.07.png

(Renato N) #5

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:

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


(Mark Piller) #6

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, the problem will go away.


(Renato N) #7

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 :slight_smile:

(Renato N) #8

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 :slight_smile: