I have a Raspberry Pi and I am developing an application on the Pi that can be controlled by a web portal.
So I need to know, if I change something in my website, how will that be transferred to my Pi which is a client without any pull request from the client.
One solution could be to install Apache on your Raspberry and setup a basic http PHP or Python API. When a change is posted on the website, the back-end script makes a API call to the Raspberry API service.
If you are using PHP as your web server, you could use json_decode(file_get_contents(...) to access the Raspberry API.
I'll suggest you to use Websockets.
Websockets are bidirectional and client and server can communicate whenever they want as TCP session is ongoing. So, yo will not need to do polling.
You can download and compile libwebsockets for your raspberry as server or as I did in one of my previous projects, you can install nodejs into the raspberry and use socket.io library to handle all. Of course, you will need to do some modifications in your web page to behave like websocket client or socket.io client.
Good luck!
Related
I've started testing edgeSDK in a prototype IOT environment.
The idea is to connect devices with sensors and other nodes (Raspberry Pi, ESP8266, macOS, etc.) and exchange data or messages between them on the edge, trying to avoid communicating through the cloud.
(I will be also "mirroring" this exchanges in an AWS central cloud environment, to establish some comparisons/evaluations).
At this point, I have edgeSDK running on macOS and the Raspberry Pi and would like to add ESP8266 into the mix.
My Question is:
Can I get ESP8266 to work with edgeSDK? I don't see it listed as a supported platform.
If yes, which OS? (I was thinking about Mongoose, keeping the JavaScript coding and follow the standard).
Any other comments/suggestions or similar references would be very welcome!
ESP8266 is a microcontroller, which edgeSDK does not support. However, you can run a RESTFul API client on ESP8266 to call a API served by a microservice hosted by edgeSDK on a Raspberry Pi for example.
We are building an Android App and we are worried about the REST API being scraped.
Would it be possible to detect the REST endpoints used for the app if somebody manages to install the app in a computer and uses a software like Wireshark to sniff the connection?
The connection is HTTPS
If possible, what is the way of preventing people from using these REST APIs on their own?
We are building an Android App ... if somebody manages to install the app in a computer
I.e., you're worried about either 1) a computer running Android or whatever Google's "Android+Chrome merge" thing is or 2) a computer running some software under which Android apps can run?
and uses a software like Wireshark to sniff the connection? ... The connection is HTTPS
Sniffing an SSL/TLS connection gives you a bunch of encrypted data unless you give Wireshark enough data to decrypt it, and it's a situation where it can decrypt it.
However, a debugging proxy such as Fiddler or Charles might be able to catch the traffic and decrypt it in situations where Wireshark couldn't.
I have a Java desktop application, which needs to be updated with data from a web server continuously.
Since the desktop application could be used in a mobile environment (e.g. on a laptop with a 3G modem), there is no way to connect with it through the client's IP address.
What is the 'best practice' on pushing data to a [mobile] client from a server?
I have heard that Comet is a new emerging technology, does something similar exist for desktop (non-browser) applications?
By the way, what is the most mature technology for doing that in a web browser client? Comet, HTML5 or anything else?
Comet really has nothing to do with the web aside from it's use of HTTP. The client (web page or desktop application) simply opens an HTTP connection, and it's up to the server to keep it open until it has something to tell the client. If/When the http connection times out on either end, the client simply makes another HTTP call to the same endpoint.
super basic question - I am building an iphone app but will need to set up my computer as a server so my app can send data to my computer. what are the first steps that i need to take?
Thanks!
If you are writing an iPhone app you are probably on a Macbook so you can easily enable Apache in system preferences, click sharing, enable web sharing it will then show you your computers IP address that you can hit over a web browser.
That will set you up with a web server on your machine. Since your emulator and web server will be on the same wifi network and even if you deploy to the device you can have it on your wifi network you should be able to post data to your Mac's web server.
If you are passing data to it you'll need to read about 'web services', probably REST web services. I would then suggest reading about PHP and/or Ruby or Python as your programming language to interpret what you are posting to the web service.
Hope that helps you on your way.
If you are not on a Mac you can't develop an iPhone app anyways ;) so the above strategy should work for you.
3G will only work for you if your server is available outside of the network. Tons of info online on how to set that up but essentially what you would do is configure your router to forward incoming traffic from (for example) port 8080 to the ip address of your server. Assuming you are on a router.
As a side note, if down the line you use Ruby you could check out http://www.heroku.com/how if you want to host your server there
Hosting an application on a web application server e.g. JBoss automatically brings in lots of app server specific functionalities with it e.g. security, clustering & load balancing etc. I have a situation where I have to develop a server app with which, legacy apps can talk to over TCP/IP socket as well as be highly available. Initially, I had though of using JBoss app server to leverage its clustering support for HA. However, I am not sure whether it would be possible to connect to a JBoss web app using pure TCP/IP sockets from both java and non-java apps.
What is the best way to achieve this without using web service or Http approach?
UPDATE: I am specially interested to know how legacy apps will connect to the hosted web app through TCP/IP socket.
A really simple solution to bridge the two worlds would be to add a simple Java server which maps the old TCP/IP requests to HTTP requests. This is probably a pretty braindead task, so this "server" will be simple to write and maintain. Also, this server won't need as much power since it just accepts and forwards connections (no business logic or DB code).
On the JBoss server, you develop like you normally would. The legacy apps connect to the little bridge server which passes the requests on to JBoss and translate the result back.
This ensures that you're building for the future: When new apps are developed, they can connect directly to JBoss and use all the great HTTP features.
There's no reason why you can't open up a normal socket in (say) a servlet application hosted in JBoss.
You can then get a byte stream from this. The headache is then to decide on a platform-independent representation of your messages, such that your client end can format and send such that the JBoss-hosted end can read. But it's all perfectly feasible.
I would implement a very simple http (1.0) client.