CINXE.COM

SINETStream | SINETStream

<!DOCTYPE html> <html lang="en-US"> <head> <script async src="https://www.googletagmanager.com/gtag/js?id=UA-169261303-1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-169261303-1'); </script> <meta charset="UTF-8"> <!-- Begin Jekyll SEO tag v2.8.0 --> <title>SINETStream | SINETStream</title> <meta name="generator" content="Jekyll v3.10.0" /> <meta property="og:title" content="SINETStream" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="SINETStream" /> <meta property="og:description" content="SINETStream" /> <link rel="canonical" href="https://www.sinetstream.net/docs/tutorial-android/TUTORIAL-android-step1-overview.en.html" /> <meta property="og:url" content="https://www.sinetstream.net/docs/tutorial-android/TUTORIAL-android-step1-overview.en.html" /> <meta property="og:site_name" content="SINETStream" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="SINETStream" /> <script type="application/ld+json"> {"@context":"https://schema.org","@type":"WebPage","description":"SINETStream","headline":"SINETStream","url":"https://www.sinetstream.net/docs/tutorial-android/TUTORIAL-android-step1-overview.en.html"}</script> <!-- End Jekyll SEO tag --> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="theme-color" content="#157878"> <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> <link rel="stylesheet" href="/assets/css/style.css?v=d6f0b877a2074d7508e6b1d390a965b3d937c724"> </head> <body> <header class="page-header" role="banner"> <h1 class="project-name"><a href="/">SINETStream</a></h1> <h2 class="project-tagline">SINETStream</h2> </header> <main id="content" class="main-content" role="main"> <!-- Copyright (C) 2020-2021 National Institute of Informatics Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <p><a href="/docs/tutorial-android/TUTORIAL-android-step1-overview.html">日本語</a></p> <h1 id="tutorial---step1-send-and-receive-text-messages">TUTORIAL - STEP1: Send and receive text messages</h1> <p><em>Table of contents</em></p> <pre> 1. Introduction 2. System configuration 3. The flow of work 3.1 Works on the back-end side (part 1) 3.2 Works on the Android side 3.3 Works on the back-end side (part 2) 4. Restrictions 5. If something goes wrong 5.1 Want to reset the Android application settings 5.2 The Android application cannot connect to the Broker 5.3 An error dialog is shown while the Android application is running </pre> <h2 id="1-introduction">1. Introduction</h2> <p>As the first step of a sample program which uses the Android SINETStream library, we demonstrate a simple system configuration.</p> <p>It is a kind of echo back system. An Android application sends a message (such like “Hello World”) to the <code class="language-plaintext highlighter-rouge">Broker</code>, then the <code class="language-plaintext highlighter-rouge">Broker</code> sends it back, and finally the Android application receives it.</p> <h2 id="2-system-configuration">2. System configuration</h2> <p>In this scenario, we use an Android application “Echo”, which has both <code class="language-plaintext highlighter-rouge">Writer</code> and <code class="language-plaintext highlighter-rouge">Reader</code> functionalities, and a <code class="language-plaintext highlighter-rouge">Broker</code> functionality on the back-end side.</p> <p><img src="/docs/tutorial-android/images/step1/system_model.png" alt="System model" /></p> <p>For better readability of this tutorial, we describe details per functional elements</p> <ul> <li>Works on the back-end side</li> <li>Works on the Android side</li> </ul> <p>in the latter part of this document. Please proceed along with those descriptions.</p> <p>Once you went through the running environment installations, you need to fill-in the connection settings between the Android and the <code class="language-plaintext highlighter-rouge">Broker</code>, before actually run the Android Application. Please set parameters to fit with your network configurations.</p> <h2 id="3-the-flow-of-work">3. The flow of work</h2> <h3 id="31-works-on-the-back-end-side-part-1">3.1 Works on the back-end side (part 1)</h3> <p>The Android application for this tutorial contains both <code class="language-plaintext highlighter-rouge">Writer</code> and <code class="language-plaintext highlighter-rouge">Reader</code> functionalities, and both of them use the identical <code class="language-plaintext highlighter-rouge">Broker</code> connection parameter sets (Address, Port, Topic Name). Therefore, no special handling for the <code class="language-plaintext highlighter-rouge">Broker</code> is needed.</p> <p>It is enough only if the Android application can connect to the peer <code class="language-plaintext highlighter-rouge">Broker</code>.</p> <p>If there is an active <code class="language-plaintext highlighter-rouge">Broker</code> which has used for other tutorial, you can use it as is. Here we demonstrate a sample usage that only the MQTT <code class="language-plaintext highlighter-rouge">Broker</code> functionality is used while other elements of the back-end system for the other tutorial (TUTORIAL-ANDROID-STEP2) left untouched.</p> <p>If the back-end system for the TUTORIAL-ANDROID-STEP2 has not yet started, go through the chain of works (install the <code class="language-plaintext highlighter-rouge">Docker Engine</code>, install and run the container image) by following the <a href="/docs/tutorial-android/sinetstreamhelper-tutorial-container/TUTORIAL-docker-container.en.html">Tutorial DOCKER-CONTAINER</a> document.</p> <div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go"> % sudo docker run -d --name broker -p 1883:1883 -p 80:80 harbor.vcloud.nii.ac.jp/sinetstream/android-tutorial:latest </span></code></pre></div></div> <p>With this <code class="language-plaintext highlighter-rouge">docker run</code> command, installation of the back-end system and starting of server processes are automatically executed.</p> <h3 id="32-works-on-the-android-side">3.2 Works on the Android side</h3> <p>We describe procedures such like installation, settings and operations of the Android application “Echo”.</p> <p>Please see the companion document <a href="/docs/tutorial-android/TUTORIAL-android-step1.en.html">TUTORIAL - Android:STEP1</a> for details.</p> <h3 id="33-works-on-the-back-end-side-part-2">3.3 Works on the back-end side (part 2)</h3> <p>Once you have done this tutorial, computational resources for it must be freed. Please stop and remove the container image with the following commands.</p> <blockquote> <p>If the Android application is still running, you will see an error dialog “EOF exception”, because the connection is closed by <code class="language-plaintext highlighter-rouge">Broker</code> shutdown.</p> </blockquote> <div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="go"> % sudo docker stop broker % sudo docker rm broker </span></code></pre></div></div> <p>Please see the companion document <a href="/docs/tutorial-android/sinetstreamhelper-tutorial-container/TUTORIAL-docker-container.en.html">TUTORIAL-DOCKER-CONTAINER</a> for details.</p> <h2 id="4-restrictions">4. Restrictions</h2> <p>Because of the nature of tutorial which aims to experience the system behavior, this tutorial does not fully cover the Android <code class="language-plaintext highlighter-rouge">SINETStream</code> library functionalities.</p> <p>If you use the <code class="language-plaintext highlighter-rouge">Broker</code> shown in this tutorial, beware that there are some functional restrictions as follows.</p> <ul> <li>Connection method with <code class="language-plaintext highlighter-rouge">Broker</code> <ul> <li> <p>The Android application connects to the <code class="language-plaintext highlighter-rouge">Broker</code> with the simplest way; no user authorization, no SSL/TLS, no encryption.</p> </li> <li> <p>For the sake of simple processing, the <code class="language-plaintext highlighter-rouge">Broker</code> does not distinguish each Android clients. Actually, multiple Android clients can connect to the same <code class="language-plaintext highlighter-rouge">Broker</code> at the same time. In that case, a message sent by a <code class="language-plaintext highlighter-rouge">Writer</code> will be re-distributed to all <code class="language-plaintext highlighter-rouge">Readers</code>.</p> </li> </ul> </li> </ul> <h2 id="5-if-something-goes-wrong">5. If something goes wrong</h2> <h3 id="51-want-to-reset-the-android-application-settings">5.1 Want to reset the Android application settings</h3> <ul> <li>Reset everything to restart from scratch. <ul> <li>Exercise the following steps to clear local data of the application.</li> <li>There are two kind of areas, <code class="language-plaintext highlighter-rouge">Storage</code> (or <code class="language-plaintext highlighter-rouge">DATA</code> in older Android versions) and <code class="language-plaintext highlighter-rouge">Cache</code>.</li> <li>We need to clear <code class="language-plaintext highlighter-rouge">Storage</code> area for reset operation.</li> </ul> </li> </ul> <div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> Settings --&gt; Apps &amp; notifications --&gt; App info --&gt; Echo [FORCE STOP] --&gt; Storage &amp; cache --&gt; Clear storage (or CLEAR DATA) </code></pre></div></div> <h3 id="52-the-android-application-cannot-connect-to-the-broker">5.2 The Android application cannot connect to the <code class="language-plaintext highlighter-rouge">Broker</code></h3> <ul> <li>An error dialog something like “Cannot connect to the Broker” is shown. <ul> <li>Make sure the Android device is connected to the external network via cellular or Wi-Fi (= not in airplane mode).</li> <li>Make sure the <code class="language-plaintext highlighter-rouge">Broker</code> is up and running on the back-end side.</li> </ul> </li> <li>Connection attempt to the <code class="language-plaintext highlighter-rouge">Broker</code> timeouts. <ul> <li>Check the IP address (or FQDN) and port number of the <code class="language-plaintext highlighter-rouge">Broker</code>. <ul> <li>FQDN: Fully Qualified Domain Name</li> </ul> </li> <li>Check the IP routing between the Android device and the <code class="language-plaintext highlighter-rouge">Broker</code>.</li> <li>There may exist firewall along the route. If so, check its settings.</li> </ul> </li> </ul> <h3 id="53-an-error-dialog-is-shown-while-the-android-application-is-running">5.3 An error dialog is shown while the Android application is running</h3> <ul> <li>An error dialog something like “EOF exception” is shown. <ul> <li>It means the network connection with the <code class="language-plaintext highlighter-rouge">Broker</code> is lost.</li> <li>Check the connection status of the Android device.</li> <li>Check the status of the back-end container.</li> </ul> </li> </ul> <footer class="site-footer"> <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a>.</span> </footer> </main> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10