iOS Simulator-Compatible Libraries or Universal Versions for Solace SDK

srikanth
srikanth Member Posts: 15 ✭✭

I have downloaded the iOS support libraries from the Solace website (). However, when I try to run my app on the iOS simulator, I encounter the following error:

"Building for 'iOS-simulator', but linking in object file(s) built for 'iOS'"

This error is occurring for the following libraries:

  1. libsolclient.a
  2. libcrypto-universal.a
  3. libssl-universal.a

Could you please provide libraries that are compatible with the iOS simulator or universal libraries that support both iOS devices and simulators https://solace.com/downloads/

Answers

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 668 admin

    I'm 99% sure the Solace iOS SDK is not supported anymore… not for a long time. You'd probably want to look at a compatible MQTT or AMQP library instead.

  • srikanth
    srikanth Member Posts: 15 ✭✭

    Hi @Aaron,

    Thanks for the quick response! I appreciate the clarification regarding the Solace iOS SDK.

    Given that the SDK is no longer supported, I’m definitely open to using a compatible MQTT or AMQP library to implement the publish/subscribe functionality. Could you please point me to any recommended libraries or provide links to relevant documentation that can help with integrating either MQTT or AMQP into an iOS app?

    Additionally, if you have any code samples, resources, or guides that demonstrate how to implement WebSocket communication with a message queue (specifically for subscribing, publishing, and handling queues), that would be extremely helpful.

    Looking forward to your guidance!

    Best regards,
    Srikanth.

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 668 admin
    edited January 21 #4

    Hey @srikanth , I'm not sure if we officially have any recommendations on Apple-compatible open-source SDKs that are out there… MQTT or AMQP. Maybe someone else will weigh-in here..?

    I will say that since MQTT has no concept of queues, you won't be able to use any MQTT API to connect to Solace and listen/consume from queues. Everything in MQTT is topic-based. And while the Solace broker actually does use queues as part of the implementation of QoS1 messaging, it's an implementation detail, hidden from the client app. And I'd be surprised if there was an AMQP for mobile out there.

    EDIT: MQTT is great, it just can't "bind to an existing Solace queue" if that's your use case. But for topic-based pub/sub interop with enterprise messaging applications, it's great. I use MQTT a lot of my front-end components, with Solace (JCSMP) apps in the backend.

    Any possibility to use the JavaScript API? It's the most well-baked, hardened Solace API out there for "mobile" / web.

  • srikanth
    srikanth Member Posts: 15 ✭✭
    edited January 21 #5

    Hi @Aaron ,
    As per your suggestion, I have switched to using the MQTT library to handle message publishing and subscribing. I now need to connect using a WebSocket URL (wss://) for the connection. Please review the attached document, and provide guidance or insights on how to properly implement this functionality using MQTT with WebSocket Secure (wss://) for message exchange.

  • srikanth
    srikanth Member Posts: 15 ✭✭
    edited January 21 #6

    Hi @Aaron ,
    "I've been working with the AMQP library and encountered the following error. Below, I’ve included a portion of my code to provide better context. Could you kindly review it and guide me toward a solution?"

    Code :

    let conn = RMQConnection(
                uri: "amqps://mr-connection-7q6d6fhfmd5.messaging.solace.cloud:5671",
                delegate: RMQConnectionDelegateLogger(),
                recoverAfter: 30 
            )
            conn.start()
    


    Error :
    Received connection: <RMQConnection: 0x600002dd8000> disconnectedWithError: Error Domain=GCDAsyncSocketErrorDomain Code=7 "Socket closed by remote peer" UserInfo={NSLocalizedDescription=Socket closed by remote peer}

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 668 admin

    I've been working with the AMQP library and encountered the following error

    Without digging into this, I would guess that the AMQP library you're using is specifically for RabbitMQ, which uses a pre-standard version of AMQP (0.9.1). This is not the standard 1.0 implementation, and is not compatible at all. They really shouldn't call their protocol AMQP since it's completely different than the final 1.0 spec that was released, and they're the only broker that uses it. I don't know / doubt there is an AMQP 1.0 client library for iOS… there may be?

    For your MQTT doc: note that (the default) port 8443 is for MQTT over WS; 8883 is for MQTT over TCP. So you need to configure your client library to use the correct transport protocol depending on which port you connect to. Most libs I've used can determine it based on the connection string (e.g. tcps:// or wss://). When connecting from a browser/JavaScript, WebSockets is the only option. But if using Node or Python or some other "backend" language/script, you should be able to connect with either one.

    One big suggestion I'll offer: make sure you're using an MQTT v5.0 library (vs. the MQTT 3.1.1 one you seem to be, based on logging output). MQTT v5 provides a bunch of useful new features that make it easier to integrate/interop with regular Solace-native applications… such as User Properties key/value pairs, and support for request-reply interactions. Solace works with both 3.1.1 and 5.0, but 5.0 is just better.

  • srikanth
    srikanth Member Posts: 15 ✭✭
    edited January 23 #8

    Hi @Aaron
    SUB : connect to the Solace broker from the iOS simulator using WSS and TCPS protocols.

    I am currently working on integrating an MQTT client with the Solace Broker, using the CocoaMQTT library for iOS. While I am able to successfully establish connections, publish, and subscribe to topics using port 8883, I am facing issues with ports 443, 55443 (which I am attempting to use for WSS and TCPS protocols).

    What I’ve tried:

    • Ports:
      • Port 8883: Successfully connects and works for MQTT over SSL.
      • CocoaMQTT(debug): socket disconnectedDisconnected with error: Socket closed by remote peer
    • I have attempted this with both CocoaMQTT and MQTT5 libraries, but the issue persists.

    Specific Questions:

    1. Is there any specific configuration needed on the Solace dashboard or Solace broker for using ports 443 (WSS) or 55443 (TCPS)?
      Could there be any protocol-specific configuration or adjustments I need to make on the Solace Cloud dashboardto support these ports for secure WebSocket (WSS) and MQTT over TCPS?
    2. Solace Documentation or Guidelines:
      Is there any documentation available for Solace that outlines the necessary configurations for different protocols(WSS, MQTT over TCP, etc.) or specific client-side configurations for these ports?
    3. TLS/SSL Configuration:
      For the secure connections (TCPS, WSS), I have made attempts to configure the MQTT client with SSL settings, but still encounter issues. Could there be any SSL-related configuration settings on the Solace platform that I am missing? For example:
      • Does Solace require a specific SSL/TLS certificate configuration for these ports?
      • Should I disable certain SSL validation parameters when using these ports, especially if I’m testing?
    4. Error Troubleshooting:
      What other factors could be causing the Socket closed by remote peer error? Is there any way to get more detailed logs from Solace or on the client-side to troubleshoot this further?

    Setup Information:

    • Solace Cloud Broker: [mr-connection-7q6d6fhfmd5.messaging.solace.cloud]
    • MQTT Client: CocoaMQTT / MQTT5
    • Port Used:
      • 8883 (works fine for SSL/MQTT)
      • 443 (for WSS)
      • 55443 (for TCPS)

    Conclusion:

    I would appreciate any insight or pointers towards troubleshooting this issue, especially regarding configuration requirements on Solace for different MQTT protocols (WSS, TCPS) and SSL/TLS settings. If there are any additional considerations for using these ports, I would be grateful for your suggestions.

    Thank you in advance for your help!

  • srikanth
    srikanth Member Posts: 15 ✭✭
    edited January 23 #9

    Hi @Aaron
    I'm able to connect and use port 8883 for MQTT over SSL with Solace, but I’m encountering issues when trying ports 443 (WSS) and 55443 (TCPS), with the error: "Socket closed by remote peer." Are there specific configuration settings required on the Solace dashboard for these ports or protocols? Any SSL/TLS adjustments or documentation for connecting via WSS or TCPS would be appreciated

    NOTE: Does the Solace broker support WSS and TCPS protocols for MQTT connections on iOS? I’m able to connect using port 8883 for SSL, but I’m facing issues with ports 443 (WSS) and 55443 (TCPS). Are these protocols supported for iOS, and if so, are there any specific configurations required on the Solace dashboard?

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 668 admin

    Hey @srikanth… the port 55443 is for SMF (Solace Message Format) (our "native" protocol) over TCPS. Port 443 (in Solace Cloud) or 1443 (for self-managed software brokers) is for SMF over WSS. You can't connect an MQTT client to these ports. See the software broker section of this: https://docs.solace.com/Admin/Default-Port-Numbers.htm

    For MQTT, you'd need to connect to either port 8883 for TCPS, or 8443 for WSS. Again, these are default port values, and might be different on your broker? If you have a software broker with multiple Message VPNs, the MQTT ports might definitely be different. Best to check by going into PubSub+ Manager, on the "Message VPN" tab on the left, click the "Services" tab on the top, and scroll down to the MQTT section.

    Looking quickly at the CocoaMQTT API, it appears to support both regular TCP connections, and over WebSockets by passing that socket object into the CocoaMQTT5 constructor. So hopefully trying the correct ports will help..!

  • srikanth
    srikanth Member Posts: 15 ✭✭
    edited January 24 #11

    Hi @Aaron,
    Hi Aron,

    Below are the results when using WebSockets by passing that socket object into the CocoaMQTT5 constructor. I went through the Solace service dashboard and tested different ports, encountering several connection issues. Here’s a summary of the results:

    1. Plain Text (Port 1883)

    • Error: Connection times out.
    • Logs:
      • NSURLErrorDomain Code=-1001 "The request timed out."
      • MQTT client state: Disconnected.
    • Telnet Test:
      • telnet mr-connection-7q6d6fhfmd5.messaging.solace.cloud 1883 fails with operation timeout.

    2. TLS (Port 8883)

    i. WebSockets by passing that socket object into the CocoaMQTT5 constructor

    • Error: Network connection lost after initiating SSL handshake.
    • Logs:
      • NSURLErrorDomain Code=-1005 "The network connection was lost."
      • MQTT client state: Disconnected.
    • Telnet Test:
      • telnet mr-connection-7q6d6fhfmd5.messaging.solace.cloud 8883 connects but the connection is immediately closed by the host.

        ii. without passing WebSockets by passing that socket object into the CocoaMQTT5 constructor

    logs:

    [TRACE] [didStateChangeTo]: new state: connected

    Coonnected

    3. WebSocket (Port 8000)

    • Error: Request times out.
    • Logs:
      • NSURLErrorDomain Code=-1001 "The request timed out."
      • MQTT client state: Disconnected.
    • Telnet Test:
      • telnet mr-connection-7q6d6fhfmd5.messaging.solace.cloud 8000 times out, unable to connect.

    4. WebSocket with TSL (Port 8443)

    • Error: Connection times out.
    • Logs:
      • NSURLErrorDomain Code=-1001 "The request timed out."
      • MQTT client state: Disconnected.
    • Telnet Test:
      • telnet mr-connection-7q6d6fhfmd5.messaging.solace.cloud 8883 connects successfully but the connection is closed by the remote host.

    iOS Code Implementation:

                let clientID = "CocoaMQTT5-\(animal!)-" + String(ProcessInfo().processIdentifier)
                let websocket = CocoaMQTTWebSocket(uri: "/mqtt")
                websocket.enableSSL = true
                mqtt5 = CocoaMQTT5(clientID: clientID, host: defaultHost, port: 8000, socket: websocket)
    
                let connectProperties = MqttConnectProperties()
                connectProperties.topicAliasMaximum = 0
                connectProperties.sessionExpiryInterval = 0
                connectProperties.receiveMaximum = 100
                connectProperties.maximumPacketSize = 500
                
                
                mqtt5!.enableSSL = true
                mqtt5!.connectProperties = connectProperties
                mqtt!.username = "solace-cloud-client"
                mqtt!.password = "iieqm7mkcdt1q0i83qr4pqq998"
                mqtt5!.logLevel = .debug
                mqtt5!.keepAlive = 130
                mqtt5!.delegate = self
    

    Please let me know if you need further details or assistance in troubleshooting the connection issue.

  • srikanth
    srikanth Member Posts: 15 ✭✭

    Hi @Aaron

    I hope you're doing well. Would it be possible for us to communicate via Microsoft Teams to go through the code and the Solace service dashboard together? I believe a live walkthrough would allow me to quickly demonstrate the issues I'm encountering, and we can work through them more effectively.

    By sharing my screen, I can show you the exact configuration and the current status of the connections. This might help in resolving the problem much faster.

    Please let me know if you're available for a brief session, and feel free to suggest a time that works best for you.

    Looking forward to your response.

    Best regards,
    Srikanth.

  • srikanth
    srikanth Member Posts: 15 ✭✭
    edited February 14 #13

    Hello @Aaron,

    I hope you're doing well. In our previous discussions, we've explored how Node.js and Python developers can establish a secure handshake with Solace PubSub+ brokers using certificates and VPN names. Now, I'd like to focus on how we can achieve a similar secure connection in an iOS application using the CocoaMQTT5 library.

    Objective:

    We aim to configure the iOS MQTT client to connect to the Solace broker by specifying the VPN name, similar to the Java implementation.

    Java Implementation Reference:

    private static final String VPN = "general-us10-dev"; // Your VPN name
    private static final String HOST_URL = "tcps://appgendv-us10.messaging.solace.cloud"; // The Solace host URL
    private static final String KEYSTORE_PATH = "/path/to/keystore.jks";
    private static final String KEYSTORE_PASSWORD = "yourKeystorePassword";
    
    public static void main(String[] args) {
        try {
            // Step 1: Create Solace connection factory
            SolConnectionFactoryImpl connectionFactory = new SolConnectionFactoryImpl();
    
            // Set various connection properties
            connectionFactory.setVPN(VPN);
            connectionFactory.setHost(HOST_URL);
            connectionFactory.setAuthenticationScheme("AUTHENTICATION_SCHEME_CLIENT_CERTIFICATE");
            connectionFactory.setSSLKeyStore(KEYSTORE_PATH);
            connectionFactory.setSSLKeyStorePassword(KEYSTORE_PASSWORD);
            connectionFactory.setSSLValidateCertificate(true);
    
            // Step 2: Create connection and session
            Connection connection = connectionFactory.createConnection();
            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    

    iOS Implementation with CocoaMQTT5:

    To replicate this setup in an iOS environment using CocoaMQTT5, we need to configure the MQTT client to specify the VPN name and handle SSL/TLS certificates appropriately.

    import CocoaMQTT
    
    let clientID = "CocoaMQTT5-\(animal!)-" + String(ProcessInfo().processIdentifier)
    let websocket = CocoaMQTTWebSocket(uri: "/mqtt")
    let mqtt5 = CocoaMQTT5(clientID: clientID, host: "appgendv-us10.messaging.solace.cloud", port: 55443, socket: websocket)
    
    let connectProperties = MqttConnectProperties()
    connectProperties.topicAliasMaximum = 0
    connectProperties.sessionExpiryInterval = 0
    connectProperties.receiveMaximum = 100
    connectProperties.maximumPacketSize = 500
    
    mqtt5.connectProperties = connectProperties
    
    mqtt5.enableSSL = true
    mqtt5.username = ""
    mqtt5.password = "" 
    mqtt5.keepAlive = 60
    mqtt5.delegate = self
    mqtt5.logLevel = .debug
    mqtt5.clearSession = true
    
    
    

    Note:

    Without specifying the VPN name, the connection handshake may not be established successfully( Java and python code base also). It's crucial to ensure that the Solace broker is configured to accept connections from clients specifying the VPN name.

    By following these steps, you should be able to establish a secure connection from your iOS application to the Solace broker, similar to the Java implementation you've provided.

    Please let me know if you need further assistance or clarification on any of the steps.