Solace + protobuf in Android application

Evgen
Evgen Member Posts: 5
edited February 2022 in Connectors & Integrations #1

Hi everyone! I'm absolutely new in Solace, so I would you to help me: my app has to communicate with Solace using protobuf models. Can you help, what to start with?

Tagged:

Answers

  • [Deleted User]
    [Deleted User] Posts: 25

    It looks like a very similar question was just asked about using Protobuf with IOS and I think Tamimi and Tom's answers should help you get started: https://solace.community/discussion/comment/1006

    If that isn't enough to get you started, let us know what you've tried to do so far and we can help out.

  • Evgen
    Evgen Member Posts: 5
    edited August 2020 #3

    Hi. Yes, I saw this link https://solace.community/discussion/comment/1006. But it didn't help me. Maybe an example can be given for android? Where can I use parameters like:

    • login
    • password
    • host
    • and VPN
  • [Deleted User]
    [Deleted User] Posts: 25

    Paging @Tamimi and @TomF - can you help Evgen out here? If not, who's our resident Android expert?

  • Evgen
    Evgen Member Posts: 5

    :( Please @Tamimi and @TomF can you help me?

    https://solace.com/downloads/
    Messaging APIs + Protocols (Java) - this for backend? or for all who write on java (backend, android ...) ?

  • TomF
    TomF Member, Employee Posts: 406 Solace Employee

    @Evgen you need to decide how the app will communicate with the Solace broker. As Tamimi suggested, MQTT is a good place to start. Once you have your app talking to the broker, you then need to decide how whatever application needs to get the data from the app will talk to the broker. This could be MQTT, JMS or our native Java API.

    So, let's start at the app to broker communication. Use our quick starts to get a broker going first. Then use an MQTT API such as Paho to send messages from your app to the broker.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin

    You can also do a quick search on how to use MQTT with android, one is the Paho Android Services (I never personally used that one before) you can read more about it here https://www.hivemq.com/blog/mqtt-client-library-enyclopedia-paho-android-service/#:~:text=The MQTT connection is encapsulated,to receive MQTT messages reliably.
    There are also other Android MQTT services you can leverage. So one path I would recommend
    1. Spin up a Soalce broker (as per the quick starts that Tom referred to)
    2. Use MQTT Android to connect to the broker
    3. Send and receive messages from your Android application over the broker

    Using the Java API from our downloads page will give you more advanced features access, the reason why I suggested MQTT at first is to get familiar with our broker and pubsub workflow. I'm curious to know how your Android application turns out to be and what it is! Would be happy if you update us on it and the progress :)

    Happy programming!

  • Evgen
    Evgen Member Posts: 5

    Thank!
    I read this blog:
    https://solace.com/blog/event-driven-kotlin-android-app-mqtt-solace-pubsub/

    But i not found where i can setting vpn for solace;
    My Solace broker get me: login/password/host and vpn;
    OK.
    MQTT i see setting host/login and password but i not found vpn.
    This my problem.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin

    @Evgen Did you attempt to connect without the msgVPN (i.e. just using host, username, password)? You can’t set magVPN if using MQTT since “messageVPN” is a Solace concept. When you connect to the broker via mqtt without setting the messageVPN it will default to the first one.

  • Evgen
    Evgen Member Posts: 5

    @Tamimi
    _Did you attempt to connect without the msgVPN (i.e. just using host, username, password)? _ Yes
    And i get error "SOLCLIENT_SUBCODe-BSG_VPN_UNAVAILABLE, responseCode 503, reason Message VPN Unavailable"

  • TomF
    TomF Member, Employee Posts: 406 Solace Employee

    @Evgen Ah ha! It sounds like you're making progress! The "Message VPN Unavailable" error is often because you're trying to connect to a Message VPN that doesn't exist. If you don't specify a Message VPN, the Solace broker will assume you're trying to use the "default" Message VPN. If you're trying to connect to a Solace Cloud instance, this won't be available - hence the error. It's also possible that you've created, say, a Docker broker instance, and your "default" message VPN is shut down - open up the manager GUI (broker IP at port 8080 in your browser) and check the default Message VPN is "Up." If you are using a cloud plan you will need to specify the message VPN.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin

    Could you give more info on your broker setup - are you running it locally using a docker image or using Solace Cloud? This error might be because your broker is not up and running

  • TomF
    TomF Member, Employee Posts: 406 Solace Employee

    @Tamimi has reminded me that if you're using MQTT you don't specify the Message VPN - that's done by connecting to the correct port number. Nicely done Tamimi!
    So, can you share with us what your Message VPN name is, what port number the MQTT service is on that VPN, and your MQTT code?

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 491 admin

    And a code snippet on how youre attempting to connect would help alot as well 😄

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

    Hi @Evgen . Did you manage to get your Android app connected to Solace? As explained above, since a "Message VPN" is a Solace concept and not an MQTT one, the way to connect to particular VPNs is specified via the port. If using Solace Cloud, the ports are already assigned. E.g.:

    If you are running the Software broker locally, you may need to configure the MQTT port mapping to your VPN. You can find this in the PubSub+ Manager, in the Message VPN -> Services.

    Post up some screenshots / code snippets to help us help out..!

    Finally, I don't believe the standard Solace Java API (JCSMP) will work with Android. Even though Android is mostly Java. But I haven't tested myself.