I want to make HTTP requests to a server (such as Node-red or Arduino) on my LAN directly from my Google Assistant.
I would like to reproduce the behavior of this widget which, however, does not work from google assistant.
Using the IFTTT with webhooks makes the IFTTT website to ping on the internet from their server, not from my mobile in my private LAN. I think same will happen if I use google actions with api.ai with webhook. For example, this app, Wake On Lan can LAN requests, but it won't take links like 192.168.0.2:1880/test, it only takes IP addresses, but it works with the Google Hot word, OK Google.
So how can I make HTTP POST requests directly from my Google Assistant?
I'm not 100% sure what you are looking to do here, but I THINK ngrok might be able to help you.
If your goal is to be able to access a server that is only accessible within your local network, then what you really need is a way to make that server accessible from outside the network, but only to you. You have two ways of doing this. One is to open up a port on your router, which is inherently unsafe. The other is to use ngrok. ngrok is an application that you run on your local server which opens a secure tunnel into your local network. You access it using a url externally that looks like this:
https://02355cab0.ngrok.io/
The hash is unique and only you know it. That URL is accessible from anywhere on the internet, but points to a server on your local LAN, ie:
https://02355cab0.ngrok.io/ -> http://192.168.0.2:1880
Check it out here:
https://ngrok.com/
Using this ngrok url then, you can give that to the Google Assistant or whatever app (IFTTT if you want), to make calls from the web directly to your local network.
Related
I am currently creating a remote control app which uses IP control to control devices. I have created this and now I am looking to add a way for you to say for example, "OK Google, Power on 'device' in 'app name'". I have looked at Google's app actions console and I could not find a way to make this as a custom command. I have seen that there is a way to do this by adding deep links into my application. However everywhere I look this requires me to have a host web server which I do not want. Is there any way to do this without a web host or otherwise using the device as it's own host or it's own fulfillment server within the app?
The URL may or may not be resolvable by an HTTP client and it won't send a request to this links. Alternatively, you can also define a custom URL scheme. e.g. myapp://example/{foo}.
https://developers.google.com/assistant/app/action-schema#fulfillment
I have made a rest api with database for an Android app. I have made this in php in my localhost. Now I want to access it from my Android app. How can I access it through URL in internet. I am totally new to this, plz give me in details.
This question, brings back so much memories. You need to tunnel your local host packets to the public internet. There are many tools, but the main one i use is NgRok.
Details
Test mobile apps against a development backend running on your machine. Point ngrok at your local dev server and then configure your app to use the ngrok URL. It won't change, even when you change networks.
Don’t constantly redeploy your in-progress work to get feedback from clients. ngrok creates a secure public URL (https://yourapp.ngrok.io) to a local webserver on your machine. Iterate quickly with immediate feedback without interrupting flow.
A note of interest. if your app currently as a https signed certificate you might need to add some extra classes, if not you good to go. Read up here.
Guide lines for local public hosting.
Create your webserver(php,node.js etc) , start it, and verify on localhost:port
Start ngrok, its simple visit the website, the instructions are there
Ngrok will give you a url, that url is public anyone can access it, while your computer is powered on
On android side, use a http client, such as Volley, Http2 or Retrofit.
You have a few reading up to do
I want to have multiple clients that connect to a server over LAN and access/modify the mySQL database in the server.
How would i go about doing this? Can you guys provide some resources/links that i could research on the topic
To answer your question, you should be able to connect to a mysql database by adding the jdbc driver to your project as a jar file in Android Studio.
Now for a real app that you plan to distributed to thousands of users there are Security issues, Performance issues, and Scalability issues.
Security issues:
You expose your database directly to the internet by opening its port to public access for the apps to connect. A web app adds a layer in the middle, keeping the database access inside the intranet.
You expose your data directy to the public by providing at least one public account known by everybody (I assume this would be the way to access because managing one account per user wouldn't be realistic). A Web app isolates the user account from the database accounts.
By providing access this way, as android mobile devices can be rooted, you are potentially granting anonymous access to your data.
Performance Issues:
With a web app in the middle, it is the webapp who manages the
connections to the database. This enables sharing connections
amongst different users vs. one dedicated connection per user would
have if the different devices estable separate connections.
For the same reason, you can't take advantage of connection pooling,
which saves the overhed of establishing a connection to the database
for each incoming request.
Scalability issues:
As connections are not shared the number of concurrent users will be bound to the number of connections you can open at the same time to the database.
EDIT 1
I am adding an alternative I thought of which involves using a web application but it is not implemented using a webserver. It is a java NIO framework that runs on its own. The limitations of this solution is you need shell access to the server and java, which is not common in traditional hostings. Checkout Netty.
There are 2 ways how to do perform your task. You can either add the JDBC driver in android studio, or better implement a REST API that connects to your database, and all the android clients can send HTTP requests to the server and the server will add the information for you. Here you can implement the create, update, delete methods. For HTTP requests you can use Retrofit or Volley libraries.
If you want to use JDBC, check out the answer here How to Mysql JDBC Driver to android studio
But the best and most correct solution for this type of problems would be a REST Service
In the long run, you really need a "client" application between "users" and the database. It is usually done via a webserver, plus PHP/Java/VB/.... Yes, it requires you learn yet another language, but that is not something to avoid in a serious application.
The client can help (and hurt, if done adequately) with security. The client can insulate users from database changes, which will eventually happen. The client should 'abstract' the interface to the DB so that the users do not have to be SQL-savvy. Etc.
You have might installed WAMP Server / XAMPP Server for mySQL Database
Click on WAMP icon and select Apache, Open "httpd.conf" and find tag starts with
<Directory "c:/wamp/www">
...
</Directory>
and update the code as below
<Directory "c:/wamp/www">
AllowOverride All
Require all granted
Order Deny,Allow
Deny from none
Allow from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
Now Create REST APIs in your local server as you might use PHP or whatever,
and connect android app with apis with assigned IP Address to your computer in LAN.
It is not one single answer, but a group of answers. Firstly what you need is the concept of data forwarding through introspected tunnels over the network. At the end of the day, your database is always listening on certain port, that is local to your machine, meaning only you can access and modify the contents of the database. For example if you access PHPMyAdmin, you can go the MySQL address on your local machine.
What you need to do is make that access public to the internet, what you need is to broadcast your existence(internet protocol address) to the web. Thus making a public hub, in short, Local-tunnels allows you to easily share a web service on your local development machine without messing with DNS and firewall settings.
By tunneling your local machine to web , anyone with the assigned IP address can access your machine(database) over any connection,not just LAN or WI-FI. There are many options to choose from, There is ngrok,which exposes a local server behind a NAT or firewall to the internet.
Features are,
Don’t constantly redeploy your in-progress work to get feedback from clients. ngrok creates a secure public URL (https://yourapp.ngrok.io) to a local webserver on your machine. Iterate quickly with immediate feedback without interrupting flow.
Test mobile apps against a development backend running on your machine. Point ngrok at your local dev server and then configure your app to use the ngrok URL. It won't change, even when you change networks.
Building web hook integrations can be a pain: it requires a public address and a lot of set up to trigger hooks. Save yourself time and frustration with ngrok. Inspect the HTTP traffic flowing over your tunnel. Then, replay web-hook requests with one click to iterate quickly while staying in context.
Own your data. Host personal cloud services on your own private network. Run web-mail, file syncing, and more securely on your hardware with full end-to-end encryption.
Its really great, however there is a side note, because this procedure opens up your local machine and renders it IP accessible on the internet, many different security challenges arise, so it is only recommended for testing purposes with none sensitive data.
Hope this helps:)
I have searched for a solution to this but could not find one. If this is already answered, sorry, please direct me to that.
My problem is this. I have java web application running on a local intranet (Tomcat 7, Java 6, MySQL). All desktops within the intranet are connected thru LAN and access the application using the specific server IP, something like 198.162.2.10.
Now, I want to access this thru my android mobile phone as well. The entire building is Wifi enabled and I'm able to access this web application, if I know the IP and enter it in the mobile browser. But, I would like to make this mobile access automatic and wrap it in an app which on click access this automatically, even when the IP changes. We have dynamic IPs.
You can use WebView component to display a web page within your application.
As alternative you can use HttpURLConnection co perform Http request and posts to your web application.
Regarding the dynamic IP you can configure a Local dns server or assign a static IP to the server.
Anyway the application need a fixed address to connect to the web application, unless you want to insert the address manually each time.
I'm about to start development on app which is designed to communicate information to a server (hosting a web interface and storing the data) inside an intranet. I've had a large deal of programming experience but I'm wholly new to mobile app development, so the whole thing is a learning experience for me.
I guess I have more than one question:
If the intranet offers wifi, will it be easy enough to see a server existing on the same intranet?
Assuming the phone and the server are part of the same intranet network, what are the general mechanisms available to me to have them communicate?
If the intranet is not available through wifi, what's my best option? (maybe just force wifi by setting up a router?)
P.S. I'm a final year undergrad developing an app+web-app for a real organisation, be gentle with me :)
1) If the intranet offers WiFi, you're good to go, any http request will be routed to the correct local boxes.
2) HTTP requests, treat it like you'd treat an external site.
3) If you don't have WiFi, consider setting up a VPN and then in your app guide the user through setting up the VPN. Or, set up a external server (outside the intranet) that acts as a proxy to the intranet server, requiring some sort of auth before it forwards requests for you. Essentially acting as a gate keeper.
I have an wifi named with abc.where in local intranet server will use the abc wifi to access db server and my mobile app will also use the same abc wifi to access intranet server.
Use apis(webservice) of your intranet server on mobile with ip address of intranet server.