Enterprise mobility and the need to think beyond the device

For a long time, companies focused on managing phones, tablets and portable computers. But the rise of cloud computing and wearable technologies forces managers to think beyond the device, as the next generation of mobile services target businesses themselves, and could help them become more efficient.

City in mobility
Mobility of the future

The evolution of enterprise mobility

These days, mobility is more than devices and applications. Whereas the first wave of mobility allowed workers to access company services such as emails and documents from anywhere, this next iteration will help companies make more informed decisions. They will empower workers by giving them access to company data regardless of the device they use, even when they are offline, and provide managers with real-time data on how these apps are used in the workflow.

Mobility solution: TwinForce

All this without having to build a totally new or separate IT infrastructure. A solution such as MobileBridge‘s Twinforce, which relies on MOLO 17‘s technology, promises security-compliant, easy-to-implement tools that act as a transparent layer on top of the company’s current system. What’s more, it is highly customizable. It can be adapted to different work environments and form factors, such as wearable devices or smart appliances, to help workers access or share data and assets more effectively.

Sharing resources within the company, such as spaces in a coworking environment or vehicles in a fleet, is a cumbersome task that can be easily managed and even automated by using a dedicated mobile service. Workforce management and other human resources-related activities can also greatly benefit from this form of smarter mobile applications.

5G and the mobile world of tomorrow

When enterprise mobility emerged, IT managers implemented mobile device policies that managed devices as a whole. That approach did well on company-owned phones and computers. Users who would rather use their own devices, on the other hand, would feel that IT was given too much access and would thus be reluctant to enroll.

The next generation of mobile networks, or 5G, will decentralize even more that flow of information and data. To deliver on its very ambitious promise of instant performance, the mobile infrastructure of tomorrow will rely on a distributed model where a lot of the data crunching will be done remotely, outside of the company or even the user’s devices. That “mobile edge” can be seen as complex challenge for IT managers and CIOs, but can also rapidly become a competitive advantage for those who will embrace it to increase their efficiency and productivity.

Those next-generation mobile networks are only now being deployed, but enterprise applications already exist that will take advantage of them as soon as they become available. This promises a shift in the enterprise world similar to what happened years ago when the first wave of mobility occurred.

Except that, this time, it is not about devices. It is about services and applications that will empower employers and employees to be more efficient, regardless of where they are or how they connect.

VR Medical training: the virtual simulation for UniUD X-Ray technologists

An extremely interesting project in the serious game portfolio from MOLO17 is, without a doubt, the UniUD – CT Trainer or, with its working title, MIMICT (Mimic + CT), as anticipated in the previous article dedicated to the advantages of using AR / VR for medical training. The project was born from a collaboration between MOLO17 and the University of Udine (Italy) and it is targeted to the X-Ray technologist degree programme.

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Demo – UniUD CT Trainer

The final product is a simulation software VR that recreates the experience of executing a broad range of CT (computed tomography) examinations from the X-Ray Technologist point of view, simulating both the patient’s interactions and the scanner usage.

Although, in this specific project, it has not been possible the use of technologies that involve “important” forms of persistence, such as Couchbase, new and different scenarios can also be opened. For example, solutions for remote supervised training can be developed and, for students, exercises and exams can be created directly online whose outcome is verifiable without having to be physically present. This has obvious and interesting implications, as the student is enabled to experience everything from home, a key possibility for any educational institution in the face of the present post-covid situation.

Virtual simulation of X-Ray room
Virtual simulation of X-Ray room

Here we will tell you about the rationale behind this tool’s existence and its peculiarities.

Training of X-Ray Technologist: CT Trainer is the solution

The training course for students of X-Ray Tech course is strongly connected to the hospital context. According to the italian law, some hundreds of internship training in different radiology specialties, units and modalities are mandatory for the degree to be a valid title in order to access the X-Ray Tech Board examination and obtain the professional license.

The exact ways to carry out the internship do vary from a University/Teaching hospital to another, but there are some constant elements, such as the closest possible monitoring from a tutor over one or two of the students that are assigned to him/her, during the normal working hours. The academic year is usually divided into alternating periods, one when the students learn the theory and another when the students undertake their exams and internship.

Pain Points

All of the above creates multiple problems that are hard to manage and that may disrupt the learning experience and quality, while taking a toll on the hospital’s insurance costs.

Law and rules

The usage of X-Ray energies on living patients is tightly regulated and the exercise of sanitary and medical professions without a license is harshly punished. This implies that the student won’t be able to actually deliver the radiation dose on the patient and will be able only to partake in setting up the exam under the tightest possible surveillance of his or her tutor.

Human interactions

The student, entering a radiology ward for the first time, has to quickly learn how to relate with the patient, with other X-Ray techs and other types of medical and healthcare operators. In the meantime he or she has to learn using the machines and the connected devices.

Also the interaction with the patient is strictly regulated by law and it has strong legal implications that contribute to rising insurance costs. 

Machine availability

Some modalities (especially CT and MRI) are a precious resource and are usually always in use for clinical reasons, so they are not available to the students to experiment on them with mannequins and dummies.

Clinical risk and insurance claims

The presence on the field of in-training operators is always considered an additional risk factor from a clinical perspective and regarding possible insurance claims and costs, in an environment that is already one of the riskiest.

Due to the above considerations and criticalities one of the future and present solutions in healthcare is the use of simulative technologies. That being said, classic simulation approaches with mannequins and dummies are not always feasible in radiology due to availability of machinery, costs and risks connected with the use of x-ray energies.

Virtual simulation, the answer is: CT Trainer

As some of our followers already know, I experienced first hand all those problems and pains, having walked the path above from getting the degree and the professional license and ending up being a registered X-Ray Technologist, albeit not practicing the profession at the moment. Together with the heads of the academic course, we more than once envisioned the idea of making a similar tool. Finally, thanks to MOLO17, it became a reality.

The final product, based on the Unity engine, is very similar to an FPS game, where the student can freely move around a model of a CT radiology ward, perfectly fitted with a control room, gantry room, infirmary and waiting room.

The student will meet the patients, he/she will have to pick them up from the waiting room and talk to them with a multiple answer interface, in which some answers will bring negative clinical and legal consequences, other will be only partially correct, and other are the best practice possible.

The patient in the CT machine during the exam
The patient in the CT machine during the exam

After receiving the patient, the student will walk him or her to the infirmary or the machine, depending on the need to apply a cannula for the contrast agent or not, as required by the current exam’s protocol that the student must know.

In the gantry room, the student will tell the patient to lay down in the CT machine, but not before having told him or her to remove the clothing and personal belongings that might interfere with the examination.

The most technically complex and really challenging part for MOLO17’s developers has been the control console in virtual simulation. We simulated a typical CT interface with a multi monitor setup. 

Of the three monitors, two are dedicated to the CT machine, while the third one is the remote control for the automatic contrast agent injector. On the latter, the student is required to set injection speed and dose of saline and iodine, if the exam protocol requires so.

The student will then need to set all the parameters required to execute the exam protocol and image reconstruction settings, learning optimizing the quality of the image, while balancing it with the concept of “as low as reasonably achievable dose”.

CT interface
CT interface

If the controls are like the real thing, the resulting images are even more real. All exams are created using real DICOM images acquired during real exams. Besides that, it is possible to load a CT DICOM dataset already available from a real exam, to let the student experience the said situation. This feature is really useful to let students learn protocols that only seldom performed or to learn how to examine rare clinical cases. Basically, we made a DICOM viewer inside a virtual world.

The user interaction with the images is totally similar to the one that happens on a real machine. After the exam, it is possible to review the images and discuss them with the tutor.

When the examination is complete, the student will tell the patient this in an appropriate manner according to the clinical condition and the activities performed. For example if the patient was administered a contrast agent, the student will send him or her to the infirmary to stay under observation for some time due to possible adverse reactions and will avoid to tell him or her to go home or to go back to the ward.

Our conclusion about CT Trainer

We strongly believe that this tool, that will go live very soon for the actual training of future X-Ray techs at UniUD, will be able to mitigate and potentially solve many of the pain points connected.

The main point here is not to substitute the mandatory and fundamental role of the internship with real patients, which has a human value that cannot be replaced, but instead to enhance its value. We wish that this tool in virtual simulation will help shape even more human-centered healthcare operators that will be able to provide higher and higher standards for healthcare quality and patients’ safety.

For more information on CT Trainer or on the development of virtual simulation environments, contact us on https://molo17.com/.

How immersive AR/VR can make medical training more accessible

 3D skeleton

More businesses and industries are integrating virtual and augmented reality tools in their training processes every day. Affordable and versatile, serious immersive games have emerged as an effective way to recreate real-world situations without monopolizing precious and limited resources. No sector is better positioned to benefit from it than the health and medical sector.

Virtual and augmented reality environments are easily adaptable to meet many needs across all sectors. Solutions such as the ones we develop at MOLO17 enable organizations to seamlessly and affordably benefit from AR and VR environments, regardless of the manufacturer or the platform itself, in situations of prototyping, simulating and training.

For example, it can help absorb the increasing demand for healthcare professionals in many parts of the world where medical schools are scarce. It can also help to correct faulty habits, in this new post-pandemic, social-distancing era, as well as improve the efficiency of remote training.

As the world population grows, the global medical needs expand. For instance, in order to meet the expected minimum surgical needs of the developing countries, the total number of medical experts would have to double by 2030, according to industry projections. This means new medical schools will have to be built, and medical equipment will have to be manufactured in greater quantity, thus increasing the overall cost of healthcare services.

VR: virtual platform, real-life skills

Surgeons in the operating room after virtual simulation

Off-the-shelf VR headsets are already being used by medical schools in Europe and North America. Experts are now starting to use these online virtual platforms in order to share their expertise and knowledge with under-developed countries. The technology is already helping to save lives in Asia and sub-saharan Africa.

Medical students can perform several simulated operations on any given day, with the oversight and support of a remote, skilled teacher, and try to meet a specific target time and accuracy rate. They acquire skills and identify gaps in their knowledge more rapidly than by having to submit their work in a more traditional fashion. Different skill sets can also be taught using a similar simulation environment, whether there is a need to train more surgeons, technicians or nurses. Some health professionals say that virtual environments help reduce the level of stress of new surgeons once in the operating room. The experience of going through all the steps of a procedure, even in VR, has a reassuring real-life effect.

Real-time decision-making analysis and feedback

VR and AR training tools are being used in an increasing number of professional sectors, where they are continuously being improved to provide real-time analysis and feedback. Certain training programs will use artificial intelligence and natural language processing to analyze the students’ decision-making process and communication skills in real time. This is particularly useful in a stressful environment.

It can also help develop “softer” skills, such as empathizing with the patients, showing the proper level of emotions, interacting properly with the other students and teammates during a specific procedure.

We cannot put a price on human life. But there is a cost to this rapidly increasing demand for medical professionals across the globe, and it can only be met by shifting to a more modern and versatile training environment. The virtual reality platforms offer that type of environment, at a fraction of the cost of building new medical schools, thus ensuring we can train as many healthcare specialists as the world needs. 

A concrete example of a virtual simulation in the field of medical education? To learn more, read the case study, a project in collaboration with the University of Udine (Italy), in our next article.

How to develop Telemedicine solutions with Couchbase

In a time of sanitary emergency like this, the need to be able to access all databases interactively and on the move, has become a priority, particulary in Telemedicine. This also emerges especially in view of the overload to which communications are subjected and the consequent network coverage deficiencies. Therefore, having a smart device, as powerful as it can be, isn’t enough for emergency operators such as healthcare professionals, security personnel and technicians. It is, instead, critical to use mobile applications capable of always keeping up-to-date the data with which operators interact, even offline.

In this article, MOLO17 shows how it is possible, for careful developers, to take advantage of a reliable and proven technology, such as that of Couchbase, to ensure maximum stability and effectiveness to their mobile apps in various critical sectors. In particular, we will focus on the delicate sector of the Healthcare and on applications for Telemedicine.

The reliability of Couchbase for mobile app development

Couchbase is a NoSQL database which offers catchy features for every developer. It is available for the most relevant mobile platforms with its embedded version: Couchbase Lite. This version makes available all the main features of the Couchbase Server version directly into a mobile device. Both Android and iOS are supported.

Couchbase Lite shines when it comes to mobile apps. It allows to provide to the end user a complete and reliable user experience. Thanks also to Couchbase Sync Gateway, syncing real-time data between the client and Couchbase Server has never been so easy. This grants that data are always updated, and allows to work even without internet connection on the device. Hence, the synchronization runs automatically when the device gains connection.

This replication job towards Couchbase Server makes that such data are immediately available not only for other devices but also for softwares that are able to talk with the database. Since the replication is fully integrated in the Couchbase infrastructure, it happens consistently, it is strongly tested and fully reliable, minimizing the error conditions. So let’s see some use cases in which those requirements are crucial.

Couchbase: medical solutions

The medical field is so sensitive. It involves people completely, and most of the times is crucial for the human condition. A technology that will be applied in this scope must respect the requirements that we just listed. It must be consistent and well tested, but above all it must be reliable.

Couchbase in Telemedicine

So, how can we apply Couchbase in the medical field? The simplest example concerns Telemedicine. It is an innovative weapon that now more than ever proves useful.

Let’s analyze the condition of a diabetic. Who is suffering from diabetes must make a measurement of the blood glucose on a weekly (or even daily) basis. Then, from this self-diagnosis, the patient finds out the glucose value and writes it down into a diary. The measurements trend defines the improvement or the aggravation of the pathology. If the patient takes advantage having those reports on a diary, also the doctor will find useful to consult them. And it will be really useful to receive those measures automatically and, why not, in real-time.

Telemedicine: example of a mobile app to monitor blood glucose values

So let’s involve the modern technology for finding a solution to this need. We can think to a mobile app that talks with self-diagnosis instruments and then gets the glucose value out of them. This communication between devices and app may happen over Bluetooth or using a physical connection. Once obtained, the data can be transmitted to the doctor’s management software thanks to the Couchbase Server infrastructure and Couchbase Lite. Such software may be directly connected to Couchbase, or may use data-migration solutions.

This is only one of the infinite possibilities. Let’s think then to apply this “smart” Telemedicine even to patients that suffer from unstable blood pressure or heart illness. Using Bluetooth-enabled blood pressure meters, we can apply the same flow we described to the measurements that they are already used to make. A connected mobile application stores data using Couchbase Lite. Then, thanks to the automatic synchronization with Couchbase Server, the doctor will immediately see the data using his management software.

Telemedicine: operation flow of devices with Couchbase
Diagramma di flusso dell'app mobile per monitorare i valori glicemici di un paziente diabetico
Flow chart of the mobile app with Couchbase to monitor the glucose values of a diabetic patient

This diagram shows an idea on how the flow we talked about may be built. The self-diagnosis device (in this case a glucometer) sends the measurement to the smartphone over Bluetooth. Then, the mobile app installed into the smartphone stores the data into Couchbase Lite. The process is really simple. Once stored, data are synchronized towards the cloud, thanks to Couchbase Server and Couchbase Sync Gateway. Here we can perform all the data manipulations we need. We are also absolutely free to choose the best backend infrastructure that fits best our needs, like serverless. Eventually, the doctor can access such data autonomously, as simple as accessing the management software.

Conclusions

MOLO17 is a reference partner in Italy for Couchbase and has developed several projects using its technologies. Solutions capable of optimizing them have been used in sectors ranging from Healthcare with Zulu Medical, to Industry 4.0 with MobileBridge, and finally to consumer products such as Leads Collector. Our Mobile Team developers have organized and participated in meetings, events and seminars in partnership with Couchbase staff, expanding their theoretical know-how over the time and perfecting it with their constant experience in the field.

Do you have a project that needs to communicate dynamically and reliably with measurement devices also offline?

Do you want to integrate your database with the most common mobile platforms?

Are you planning a solution for real-time monitoring of patients, processes or machinery?

Whether it be in the Healthcare, IoT for Industry 4.0, Automotive or other sectors, don’t hesitate. Contacts our experts.

#6 Couchbase Server: integrate Couchbase to your serverless backend

Do you need to use Couchbase as a database on your serverless backend? Or do you simply need a Proof-of-Concept (POC)? Discover Couchbase Server and how to use AWS Lambda with MOLO17.

Article number 5 of MOLO17 about Couchbase for the web

Couchbase Server – Introduction

In this article we will integrate Couchbase in a serverless backend, using serverless framework with Node.js, docker and AWS Lambda Layer. As a test project we will create some CRUD REST APIs which allows the user to perform various operations on the contact entity objects.

A contact will have the following attributes:

  • Name – mandatory, max length 64 chars
  • Surname -mandatory, max length 64 chars
  • Email – optional, max length 64 chars and must be a valid email address

The example project is obviously available on GitHub.

Couchbase SDK

For this project we will be using the 2.6.11 version of the Node.js SDK.The SDK is not fully javascript written, in fact the core is C written. This is a critical point for our project, AWS Lambda runs on a Linux distribution powered by AWS. 

I’m using a MacBook and if I try to use the same Couchbase dependencies used locally, also in Lambda, the last will throw a /var/task/node_modules/couchbase/build/Release/couchbase_impl.node: invalid ELF header exception.
To avoid this issue we need to install the Couchbase SDK dependency in runtime similar to that supported by Lambdas. Here we can use Docker!

No worries, in the repository you will find some scripts and utilities needed to minimize your operations.

In the following Dockerfile:

FROM ideavate/amazonlinux-node:12

WORKDIR /couchbase

COPY package.json ./
COPY package-lock.json ./

VOLUME /couchbase/node_modules

CMD [ "npm", "install" ]

we’re using the “amazonlinux” base image with Node.js 12. We’re going to copy the “package.json” and the “package-lock.json” files, and declare a volume for the “node_modules”. At the container launch we’re going to run the npm install command.

Once the image has been successfully built, we can launch the docker run command. Remember to mount the volume specifying “nodejs/node_modules” as the source folder and “/couchbase/node_modules” as the destination one. In this way in the “nodejs/node_modules” we’ll have all the dependencies of SDK that will be later packed up in a Lambda Layer.

Note: you can speed up the process by running the npm run-script build and npm run-script install-couchbase commands inside the “layers/couchbase” project folder. These will respectively build the image and run the container with the right folder mount as volume.

Serverless Framework

As introduced before, this project will use the serverless framework, which allows us to package and deploy our lambdas easily and fastly.

Once globally installed with npm install --global serverless, we can configure the AWS credentials with the sls config credentials --provider aws --key access_key --secret secret_access_key command. access_key and secret_access_key are the programmatic credentials. For more information on how to generate credentials, you can use the following tutorial.

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Tutorial – How to generate AWS credentials

Lambda Layer

Now that we have the “node_modules” with the Couchbase SDK ready to use, we can create the Lambda Layer.

First of all, what are Lambda Layers? Why do we use them in this project?

At the end of 2018, AWS announced this new service as a part of AWS Lambda. It allows to create and deploy packages separated from the Lambdas, so that we can share libraries, custom runtimes or other dependencies between lambdas on multiple accounts and/or globally.

In our case it helps to limit and unify the operations needed to install the Couchbase SDK.

Using serverless framework, the Lambda Layer definition results really simple and fast. We can just add the following on the serverless.yml.

[...]

layers:
  couchbase-node-sdk-2-6-11:
    path: couchbase
    compatibleRuntimes:
      - nodejs12.x

[...]

To refer our layer on multiple CloudFormation stacks, we can add the following definition.

[...]

resources:
  Outputs:
    CouchbaseNodeSdk2611LayerExport:
      Value:
        Ref: CouchbaseDashnodeDashsdkDash2Dash6Dash11LambdaLayer
      Export:
        Name: couchbase-node-sdk-2-6-11-layer

This allows us to use the couchbase-node-sdk-2-6-11-layer variable to obtain the layer resource identifier.

Every Lambda Layer will be mount in the “/opt” folder of each lambda container.

In the previous steps we created the “nodejs” folder with “node_modules” inside. This choice wasn’t a random one. In this way our functions can use the Couchbase SDK dependency normally, as it was a part of the deployment package. AWS will automatically extends the node dependency path with “/opt/nodejs/node_modules“.

CRUD APIs

Let’s move on to defining our CRUD APIs:

  • POST /: to create a new contact
  • GET /{contactId}: to retrieve a contact
  • PUT /{contactId}: to update a contact
  • DELETE /{contactId}: to delete a contact
Developer write codes

Use of Lambda Layer

In order to retrieve the layer previously created we can use the import function in our serverless.yml as follows.

[...]
custom:
  couchbase-sdk-layer:
    Fn::ImportValue: couchbase-node-sdk-2-6-11-layer
[...]

Now that we have our layer identifier we can add it to a Lambda as follows.

[...]

functions:
  create:
    handler: src/create.default
    layers:
      - ${self:custom.couchbase-sdk-layer}
    events:
[...]

Contact creation in Couchbase Server

Proceeding with the contact creation definition, we need to define the endpoint on the serverless.yml as follows.

[...]

functions:
  create:
    handler: src/create.default
    layers:
      - ${self:custom.couchbase-sdk-layer}
    events:
      - http:
          method: post
          path: /
          cors: true

[...]

Finally we can start to implement the create function code.

In the example function we’re going to:

  • Connect to the Couchbase cluster
  • Open the bucket
  • Validate the payload
  • Insert the contact document into Couchbase

The cluster connection and  bucket opening operations will be done during the function initialization phase and not on the execution phase. Establish a connection with Couchbase involves several TCP/HTTP message exchanges, executing these operations for each request will make them heavy.

[...]
cluster.authenticate(CLUSTER_USERNAME, CLUSTER_PASSWORD);

const bucket = cluster.openBucket(BUCKET);

bucket.on("error", error => {
  console.log("Error from bucket:", JSON.stringify(error, null, 2));
});
[...]

Note that the first line of the function implementation sets the callbackWaitsForEmptyEventLoop context property to false.

[...]
const createHandler = async (event, context) => {
  context.callbackWaitsForEmptyEventLoop = false;
[...]

This is needed to return immediately the result instead of waiting that the Node event loop empty. In our case some of the bucket connection will make the function timeout.

Payload validations are carried out immediately. If the result is negative, the function will return a 400 Bad Request status code indicating the invalid field.

Once all the validations have been passed, the document to insert will be prepared adding the Contact type property. Furthermore, the document id will be calculated concatenating the type with the :: separator and a generated UUID. These two operations are a Couchbase modeling best practices. They allow both to perform specific queries by type and to improve the readability of these.

[...]const document = {
  id,
  name,
  surname,
  email,
  type: "Contact”};

const documentId = `contact::${id}`;
[...]

At the end, to insert the document into Couchbase we are going to use the insert method of the SDK as following.

const documentInserted = await new Promise((resolve, reject) => {
  bucket.insert(documentId, document, (error, result) => {
    if (error) {
      reject(error);
    } else {
      resolve({ ...result, ...document });
    }
  });
});

Retrieve a contact in Couchbase Server

The contact retrieve function follows the contact creation logics. We will find here: the endpoint definition, the Couchbase and bucket connection and the waiting event loop disabling.

To retrieve the document we will be using the get SDK method.

[...]const document = await new Promise((resolve, reject) => {
  bucket.get(documentId, (error, result) => {
    if (error) {
      reject(error);
    } else {
      resolve(result.value);
    }
  });
});[...]

If the document doesn’t exists, the sdk will throw a code 13 error, so we can return a 404 Not Found status code to the client.

Update a contact in Couchbase Server

Same process for the contact update function. Here we will find: the endpoint definition, the Couchbase and bucket connection and the waiting event loop disabling.

To update the document we will be using the upsert SDK method.

[...]const documentUpdated = await new Promise((resolve, reject) => {
  bucket.upsert(documentId, document, (error, result) => {
    if (error) {
      reject(error);
    } else {
      resolve({ ...result, ...document });
    }
  });
});[...]

If the document doesn’t exists it will be created, the upsert method in fact inserts or update a document.

Delete a contact in Couchbase Server

Finally, we will also follow the same procedure for the contact deletion function. Here we will find: the endpoint definition, the Couchbase and bucket connection and the waiting event loop disabling.

To delete the document we will be using the remove SDK method.

[...]
const document = await new Promise((resolve, reject) => {
  bucket.remove(documentId, (error, result) => {
    if (error) {
      reject(error);
    } else {
      resolve({ contactId, ...result });
    }
  });
});
[...]

As for retrieve, if the document doesn’t exists, the SDK will throw a 13 error, so that we will return a 404 Not Found status code.

Conclusions

In this article we have seen how to integrate Couchbase in a serverless backend, simplifying operations during development usings the framework serverless and AWS Lambda Layer.

Did you like this article?
Read also the other articles of our Discover Couchbase series.

Smart working & Network Failover during COVID-19

#iorestoacasa: it’s today one of the fundamental rules to be respected to avoid contagion from COVID-19. Given these directives, smart working is the simplest solution that companies and professionals can adopt to continue their work even outside the office, if it’s possible, for business continuity.

In this article Marco Cosatto, DevSecOps of MOLO17, will explain to you how to connect an emergency failover LTE gateway to the main router with VLANs to work from home.

Marco Cosatto's desk home
Marco Cosatto’s home desk

During the COVID-19 outbreak, we will see how to connect an emergency failover LTE gateway to the main router with VLANs, keeping an eye on the aesthetics with a 3D printed dock. Let’s see how to connect to the internet and work from home in complete safety.

#IORESTOACASA – the hashtag used by workers in smart working in Italy during the pandemic

As you might have noticed, here in Italy the outbreak took its toll.
And as you can imagine we, as MOLO17, have activated the business continuity plan and immediately switched to smart working.
We gladly embraced the #IORESTOACASA (that is “I’m staying at home”) movement. As you will have been able to see from our stories on instagram, our team is working from their home desks.

  • Instagram story about Marco's smart working
  • Instagram story about Matteo Granziera's smart working
  • #iorestoacasa
  • Instagram story with MOLO17 by Klodian
  • Smart working in sunny day with mac
  • Smart working with two monitor
  • The Harbor Smart working
  • Smart working by Giovanni with four monitor

Some of us were more prepared than others. I, for example, without the pretense of being a fully fledged prepper, I was a well prepared for this, at least speaking about connectivity.
If you’d like to know what i mean you can have a look at my series of posts

I always believed that home is where wifi auto-connects. As you can imagine, during this smart working exceptional explosion, internet connectivity is totally taxed by the number of people using it. Even if I already have two internet uplinks at home, I wanted to ensure my business continuity at “prepper” level.

LTE/4G connectivity as Network failover option for smart working

As I promised in a past article, I show you how to make my third uplink, an “absolute-failover” connectivity.

It’s a LTE/4G connectivity, obviously metered. I use it only when the FTTC and the WIMAX go down simultaneously, as explained before. 

When not home, I can take the device with me to use it outside.

Network failover with Netgear Nighthawk M1 LTE router

What I’m using? An high performance LTE router by Netgear, the Nighthawk M1. Now, as you know I’m not a fan of COTS devices, but this thing included everything I needed, including both a long-lasting battery, an LTE CAT16 chip (which potentially delivers 1Gbps/150mbps of download / upload speed), and an ethernet port. The ethernet port is what I needed the most: this way the device brings the hardware, I bring the professional networking features when at home. 

Now, during this outbreak I will stay at home, and I’ll really want the internet uplink to be as resilient as possible for my smart working sessions. So the device is always plugged in to the network as an uplink.
How did I make it work as an uplink to my existing router/firewall?

VLANs instead of cables

The first problem is that on the ground floor of myhouse there is barely any signal for it, but the firewall and the main uplink is located there. 

On the first floor, where my bedroom is, there is a switch that distributes the wired network for that floor. It would be a perfect place to plug it in, but since the main router is on the ground floor and I didn’t want to route more cables down the walls, I just did it with a dedicated VLAN.

Topology Diagram VLANs

Topology Diagram VLANs

The main router is connected to the main switch with a LACP, with four gbit network interfaces, both for resilience and bandwidth. 

VLANs instead of cables: the project 

 Here’s how I did it:

  1. I created a new VLAN interface on the LACP, tagged 200
  2. After that, I also created the new VLAN on both the switches: the main switch and the first floor switch
  3. In the meantime, I set all the ports to use the VLAN as TAGGED both in ingress and egress. The only exception is the port where the Nighthawk M1 has to be plugged, that is PVID 200/UNTAGGED 200, in other words “an access port on VLAN200”, without any other VLAN on it. 
  4. Later, I set the new VLAN interface, with DHCP Client enabled, as an uplink port in the router. Subsequently, I set the proper routes,  failover routes and groups. 
  5. Since the connection is metered, I created a whitelist of hosts allowed to use it.  So you can avoid consuming traffic on frivolous things, especially if you, like me, already have the two unmetered uplinks. I can always disable the firewall rule in case of emergency. 

Finally I also put an usb power cable in the cabinet on my bedroom floor. So I can come home, plug the device to the ethernet and the usb-c connector, charging and enabling my third uplink at the same time.

Bonus for paranoid preppers: if you are actually quarantined and in smart working in your floor, doing it with VLANs instead of real cables, on an already installed network, you won’t need any physical access to anything else other than the floor switch where you already are.

COVID-19 shut down shops? Here comes 3D printing 

Now I just need to make the thing polished and nice. There are some docks for the device, but you can’t go outside to buy one right now. During an emergency like this you don’t want to go outside for stupid reasons. To avoid contagion, for now it is illegal here in Italy.

I’m also a maker and I don’t mind using my 3D printer once in a while.

I found a nice model here, that is just perfect for my needs: https://www.thingiverse.com/thing:3891372

Time to fire up Slic3r and here we are:

  • Realization of slic3r: 3D printer STL Slicer
  • The 3D printed Dock on the desk
  • Testing the Dock on the desk for smart working at home
  • Dock in the final installation for smart working at home

Conclusions

I hope this article can help you with your home network and with your smart working sessions.  

#IORESTOACASA for the good of all. 

Stay Safe and good smart working!

#5 Discover Couchbase: Couchbase Peer-to-Peer Sync

The Discover Couchbase section continues with the fifth chapter, which deals in particular with Peer-to-Peer Sync.

Peer-to-Peer Sync Couchbase

In the previous article we discovered how to make an app using the Couchbase Sync Gateway and how to replicate data by a remote Database sync. Today we are going to discover how to replicate data with a Peer-to-Peer approach, using a specific feature of the Enterprise edition of Couchbase Lite called Peer-to-Peer Sync.

Why should I opt for Peer-to-Peer Sync?

Peer-to-Peer (P2P) is an application architecture where all elements involved are peers and don’t have hierarchy among them. In our case that means that every Peer can act as client and server by itself as necessary.

Moreover, the communication via Peer-to-Peer does not require any internet connection. So it can be particularly useful in areas lacking of internet connection, zone with low connectivity, or maybe if you just want to avoid the net for any reason. 

On the other hand this technology needs that all involved devices have to be relatively close one to each other. In fact to communicate  peer devices can use: 

  • Bluetooth which has a short connectivity range;
  • Wi-Fi-Direct that requires all the devices are connected to the same Wi-Fi network.

Multipeer Connectivity Framework

Couchbase provides the SDK to use its replication system, but is up to the developer to handle the communication between peers. In fact, to deal with Peer-to-Peer connectivity and communication Couchbase suggest to use the Multipeer Connectivity Framework (for iOS platform).
This framework makes us able to discover nearby devices and ask for connection.

After that, it begins the authentication phase, when the two peers can authorize the connection by a custom protocol.

Once connected, we are free to communicate with other peers.

Establishing a connection

The main characters here are:

  • MCNearbyServiceAdvertiser: something like a broadcaster, it publishes the service that will be searched by the browser. Moreover It provides some info to ease the discovery;
  • MCNearbyServiceBrowser: the Advertiser’s service detector. It searches for services offered by nearby devices using infrastructure Wi-Fi, peer-to-peer Wi-Fi, and Bluetooth (in iOS) or Ethernet (in macOS and tvOS). It provides the ability to easily invite those devices to a Multipeer Connectivity session.

Once the browser detects the service it can start the connection between the two devices.

Sending and receiving data

After establishing the connection, the session starts.
The session handles device connection and communication, as a matter of fact we can send data thanks to its method func send(_:toPeers:with:), and through its delegate methods func session(MCSession, didReceive: Data, fromPeer: MCPeerID) we are able to detect the received data.

In fact, when the data are sent using the method above, the MCSessionDelegate will trigger the didReceive method.
At this point the data received, you can manage it as you want.

Couchbase Peer-to-Peer Sync

The keypoint of the Couchbase Peer-to-Peer Sync feature is the automatic replication among different databases. This Couchbase feature is a layer of abstraction above the communication framework, which takes care about storing sent or received data.

Main characters of Peer-to-Peer Sync

The main characters involved in this feature are:

ActivePeer and PassivePeer

Couchbase splits peer behaviour in ActivePeer and PassivePeer.
The ActivePeer is the Peer who starts the connection and which sends data. Something like a client.
The PassivePeer is the peer who accepts the connection and which receives data, unlike the ActivePeer it acts as a server.
However ActivePeer and PassivePeer are different sides of the same Peer. Sometimes we need an ActivePeer, sometimes we could need a PassivePeer.

ActivePeerPassivePeer
DatabaseDatabase
ReplicatorMessageEndpointListener
MessageEndpointConnectionMessageEndpointConnection

As we can see from the table above, the main difference between the two Peers is that ActivePeer is associated to the Replicator, and the PassivePeer is associated to the MessageEndpointListener. As a matter of fact the PassivePeer is just meant to “listen” to changes coming from the ActivePeer (which started the replication process) and to replicate them.

Sending data with Peer-to-Peer Sync

As we said during the introduction Couchbase Peer-to-Peer Sync feature is an abstraction above a communication framework. This means that we have to handle by our own the communication between peers.

In fact the MessageEndpointConnection is a protocol we must implement to communicate with other peers.

For sending data to other devices we need to implement this method:

func send(message: Message, completion: @escaping (Bool, MessagingError?) -> Void)

In our case we use the MultipeerConnectivity Framework so the implementation will be something like this.

func send(message: Message, completion: @escaping (Bool, MessagingError?) -> Void) {
  do {
    try multiPeerManager.session.send(message.toData(), toPeers: 
    multiPeerManager.session.connectedPeers, with: .reliable)
  } catch {
    // handle error
  }
}

The method we just implemented will be automatically triggered as soon as we store our data in the Database. Now we just have to implement this method and store some data to start the replication.

Receiving Data with Peer-to-Peer Sync

As we just did for the data sending, we need also to enable the communication framework to receive data. In this case the SessionDelegate will pass the data to ReplicatorConnection to complete the replication.

func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {
replicatiorConnection.receive(message: Message.fromData(data))
}

Demonstration of Peer-to-Peer Sync

As a practical demonstration of this technology, we made a simple chat app integrating the Couchbase Peer-to-Peer Sync SDK. We used Multipeer Connectivity Framework to handle the communication and Couchbase Lite to store chat messages. We use replication to actually send messages to the other device. to actually send the messages to the other device.

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Couchbase Peer to Peer Sync – Demonstration

This clearly illustratets that the two devices act as ActivePeer when they send the message and as PassivePeer when they receive it.
When the send button is pressed the message is stored in the ActivePeer DB. Thanks to the Peer-to-Peer Sync solution, replication is automatically sent to the PassivePeer. The method 

func session(MCSession, didReceive: Data, fromPeer: MCPeerID)

is triggered and the 

replicatiorConnection.receive(message: Message.fromData(data))

tells to PassivePeer to accept the incoming data, to parse them and to store them in the local database.

I hope you enjoyed the reading about Couchbase Peer-to-Peer Sync. Stay tuned for more!
If you missed the articles in the Discover Couchbase with MOLO17 section, click here to read the series.

Serverless 101: first overview

In this article we are going to take a look at the serverless world in order to understand what it is and what are the main advantages/disadvantages, beyond the hype.

Serverless 101
Serverless 101

What does Serverless mean?

Surely, serverless means different things to different people.
Anyhow we can agree on the following:

  • we pay only for what we (especially the final user) actually use;
  • we have a built-in redundancy and multi AZ (Availability Zone);
  • the scaling is handled by the provider;
  • the provisioning and the manageability of the servers/containers are handled by the provider.

In other words, we don’t pay for the idle and developers don’t need to think about servers/containers anymore.
Of course serverless still has servers/container, but the key point is that we don’t care anymore about them.

Like Gojko Adzic said in one of his articles “It is serverless the same way WiFi is wireless”.

Serverless or FaaS?

The serverless term was popularized by AWS in 2014/2015 with the launch of Lambda and API Gateway services.
AWS Lambda is the perfect example of a serverless FaaS (Function as a Service) model.

In FaaS, the developer takes care of writing code (functions) which aims to solve the business problems. In this model, the function is the last layer of abstraction, it’s like splitting a microservice in smaller logical units.

We can still have an infrastructure to deal with. For example, we can use a framework on top of a Kubernetes cluster like: OpenFaaS (https://www.openfaas.com/), Kubeless (https://kubeless.io/), Knative (https://knative.dev/), etc.

By combining serverless and FaaS models, we are optimizing costs, scalability and focusing the development on the business value. Moreover we are making happy customers, managers and developers.

Limits and considerations

Of course serverless and FaaS have also some limits and challenges to deal with, unfortunately as now we didn’t find the silver bullet that solves all the problems and doesn’t have any downside.

Distributed system

These models inherit the most of a distributed system limits, such as: synchronous/asynchronous communication between services, and handle services states.
Don’t underestimate the application of specific architectural patterns and approaches based on the complexity of the project itself. Approaches such as Event Driven, CQRS, Saga are recognized as best practices and a common way to solve big issues.

Cost analysis in a serverless environment

We know that with serverless we have a significally reduction on costs, but try to calculate the real costs can be tricky. First of all we need to think about how many functions are going to be invoked and how frequently. We also need to estimate the average duration and memory allocatiocation. With these informations we can use one of the pricing calculator of our Cloud Provider and do the math.

One aspect that should certainly be considered is the free tier that is made available by the various providers which usually hovers around one million free invocations. This allows you to create a development environment at no cost.

Cold start

Another thing that serverless FaaS introduces is the cold start concept. The cold start is the time that the Cloud Provider takes to prepare and initialize the function “container” in order to actually run the code. Once warmed up, the function can handle multiple invocations. One function can take only one request at a time, so if there are multiple requests parallelized, the Cloud Provider initialize multiple functions accordingly. A warmed up function is called hot function.

Vendor lock-in

Maybe at this point you are thinking about the vendor lock-in that serverless produces.

Well, the vendor lock-in has always been a thing, but is it a big issue?

Of course it depends on your business needs: do you prefer a small TTM (Time To Market) or a vendor agnostic solution with a big TTM?

We have lock-in everywhere: a particular programming language, a framework or a third party library.

In the serverless world we can make some compromises to facilitate a provider migration. For example we can use the “serverless”  (https://serverless.com/) framework which abstract the resources and the deployment of our application in a common configuration file. By writing code that follows the SOLID principles and best practices we can make the provider and external services easy to replace.

Conclusion

Serverless is not the goal.
We are trying to:

  • test ideas as soon as possible;
  • continuous improvement;
  • deliver fast and quickly;
  • own less technology;
  • focus on creating business value.

Serverless right now is just the best fit.

Serverless technologies are still maturing, and every month new features are added. For example, AWS Lambda has recently introduced a configuration which allows us to maintain some already warmed up function hot, in order to limit the cold start times. It’s a continuous evolving world.

#4 Discover Couchbase: your first app with Couchbase Lite

In the previous articles we had a first look at Couchbase Lite and we discovered how to integrate it into a mobile app.

Moreover, we got aware of Couchbase Sync Gateway in this article for synchronizing data with ease across all our apps installations. With this post I want to finally show you those technologies in action!

Couchbase Lite - your first app

The contacts app with Couchbase Lite

For the sake of this series, we developed a sample application for both iOS and Android. This app allows you to create your personal address book with all your contacts, and sync it in real time across all your devices which have the app installed. Contacts are persisted using Couchbase Lite, as we have seen in the previous post. Thanks to the fact that the data are actually saved into the database and not explicitly sent to a remote server, we can work in absence of network without any sort of problems. This ensures a full offline user experience, with no potential lags due to a slow connectivity or any kind of network failures. All the replication is made possible out-of-the-box by the Couchbase library.

Features

Opening the sample app, you will see the list of all the contacts you added into your synced address book. You can add a new contact by pressing the “+” button. Also, by clicking on a list item you can edit the contact info as you prefer. Eventually, you can delete a contact directly from the contacts list.

Demonstration of Couchbase Lite

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

This video shows a real-time data synchronization between two instances of the same app, running both on iOS and Android. This app acts as a basic address book that allows to manage the contacts of the user. Thanks to Couchbase Sync Gateway, all the data replication process is made possibile with ease.
In particular, when creating, editing or deleting an address book Contact, the change is immediately spread to all the connected devices.

Works like a charm! You can find all the application sources in our GitHub repositories:

As mentioned in the readme files, you need a running Couchbase Server and Couchbase Sync Gateway instances for replicating data. If you don’t have such instances up and running, you may want to have a look at my previous blog post! Let’s setup them on the fly! 

That’s all, thanks for reading and stay tuned for more!

Easy with GlueSync: connect E2000 (Euro2000) ERP with your mobile app

In this article we will have an overview on how MOLO17 has easily integrated a customer’s ERP to the Twinforce WFM app in just a bunch of hours without writing a line of code thanks to the GlueSync connector developed by its partner company MobileBridge.

The common need for interfacing between ERPs and mobile applications

In a period in which the world of industry is moving towards 4.0 and therefore towards the increasingly pervasive digitization of production flows, mobile devices are acquiring a fundamental strategic importance. Obviously, mobile devices by themselves are of no use unless provided with apps and data that make them essential elements for the organization of production.

In this context, therefore, a common need arises for companies that are facing this evolution and the consequent internal innovation. The need is to have the necessary data available for consultation on the move and, above all, even if there’s no internet connection.

A common problem: ERP without interfacing APIs

From this widespread need arises a problem common to most companies that adopt ERP or MES systems whether they are defined as “legacy” and therefore obsolete from the point of view of their architecture or simply designed to operate in different scenarios: connection-oriented and fruition through desktop terminals and with interfaces not designed for fruition through tablets, smartphones or via web.

ERPs are usually not natively designed for integration with third-party web services or for the display of APIs for querying and / or modifying data through what for many can be defined as “de facto standards” such as for example the common Rest interfaces for access to resources available within web services.

This causes issues when trying to connect the two worlds. A problem that very often causes the company modernization and digitalization projects to run aground or otherwise limit.

Possible solutions

Given above-said technical problem, companies have several possible solutions available according to their needs. Let’s see what they are:

ERP replacement

The most radical solution is certainly the complete replacement of its own corporate ERP with a new version, possibly web-based and natively open to integrations. This choice allows the company to make a significant generational leap but, unfortunately, comes with it enormous costs and migration times as often a change of processes and operating methods due to rigid schemes that the new management system brings with it. The software of which the company is already equipped is in the vast majority of cases widespread within the various departments in the company, accepted and tailor made thanks to the customizations that the partner, the solution provider, has been able to adapt to the business context, fully satisfying the needs of its own customer as a skilled tailor would do.

If we are comfortable with our current ERP solution, why change? Let’s find out if there is any other possible solution…

ERP customization

If the company is not willing to make a management software change, it has as an alternative available: the current solution customization done by current ERP supplier. Although this solution offers lower costs and times than previous one, it still comes with the uncertainties of building a customization of a system that may not have been designed for this purpose with unpredictable times mainly due to new logics that will have to be addressed: from the management of a multitude of concurrent access by tablets and smartphones to the same database records, to the consequent management of conflicts resolution policies on the data generated while the various devices were without access to the network or without the latest information on stocks or blocks imposed on particular orders or customers. The scenarios to consider can be manifold.

GlueSync

GlueSync is a newly developed connector that allows you to connect a relational database (standard solution for ERP software) with a database designed to synchronize information to and from mobile devices.

Benefits of GlueSync solution

The advantages of GlueSync are guaranteed by an already developed, tested and functional solution. This means high reliability and reduced integration times.

Furthermore, by leveraging the peculiarities of mobile oriented No-SQL databases such as Couchbase (if you don’t know Couchbase or you just want to discover more about its use cases Click here), the data is directly synchronized with the mobile application without the need to build a backend exposing REST APIs to be interrogated for data recovery.

How GlueSync works

But how does GlueSync work? GlueSync uses some native services of the most popular relational databases (such as SQL Server Change Tracking) to monitor and notify in real time the changes in the data of the tables chosen for synchronization. These changes are then read and converted into non-relational data (JSON) and finally recorded into the chosen NoSQL database.

This flow can be also configured to take place in reverse mode to offer a 360° integration for read and write tasks. Even in this case, native systems are used to monitor changes (such as Couchbase’s Eventing Service) thus creating a two-way synchronization.

The connections to the two databases are configured using a convenient configuration file in which all the necessary parameters are defined, such as the list of tables for which replication has to be activated.

The case of E2000 and GlueSync

A successful case of this integration is the one with Soft System‘s E2000 (also known as Euro2000) ERP solution with which we have started a close business collaboration. Integration was carried out by configuring GlueSync to track production data into the tables of a client company that wanted to bring this information into the palm of the hand of its operators using the Twinforce WFM app.

Production data synchronized instantly

When a new production order is entered, the production cycle is assigned and the work phases are generated, GlueSync detects the change on the data and replicates them on Couchbase (target database set). Couchbase is then used as a data source for our mobile application.

See it in action

Let’s now see the operation of GlueSync connected to the E2000 management system (Euro2000) and to the Twinforce app used to display the data that previously resided exclusively within the ERP.

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.

Conclusions

Have you found yourself facing a process of renewal and / or digitization in the company and you’ve shared similar experiences to those you have found collected in this article? Do you have any experiences you would like to share with us and like to know more about GlueSync?

Visit the page dedicated to GlueSync to get in touch with our team, we will be excited to meet you.