Android - Mosquitto/MQTT - PHP/MySQL - web-services

I've a question for you.
I have to implement a queue governing the accesses to a database on Server.
The Server is in PHP and MySQL. I implemented an Android app to send and store data into DB by WebServices with HTTP Requests.
I thought to use the Mosquitto broker to implement the aforementioned "accessed queue".
First, can I use Mosquitto for this purpose? Furthermore, is it necessary to parse the HTTP Requests in the MQTT Requests and viceversa?
I'm new in MQTT. I know how it works but i don't know how implementing it. Examples in this regard are welcome! :-)
Sorry for my bad English. Thanks a lot!

You should think of MQTT as an alternative for your WebServices implementation.
Typically in MQTT your server will implement an MQTT client library (See a list here) that will subscribe (or publish) to the topics in your Mosquitto broker that your Android App will publish (or subscribe) to.
At the same time your Android App will implement an MQTT client library (Such as Eclipse Paho Android Service) to subscribe (or publish) to the topics in the same Mosquitto broker.

Related

Does QPID C++ client support SSL channel encryption with RabbitMQ broker

I am evaluating multiple C/C++ clients for RabbitMQ mesasging broker. We have gone through SimpleAmqpClient, AMQP-CPP and now evaluating Apache QPID. The deployment setup contains a RabbitMQ broker v3.6.12(with rabbitmq-amqp1.0 plugin enabled) and a QPID C++ client.
Does QPID C++ client support SSL based channel encryption and also authentication to the broker? I have gone through the documentation but I did not find a concrete example of SSL based channel encryption using QPID C++ client. However, I found examples for Java clients.
I recommend using the Qpid Proton C++ API. There's another C++ API at Qpid called "Qpid Messaging", but Proton is the better choice for new work.
The Qpid APIs in general support SSL encryption, often by using a connection URL with an "amqps:" scheme, or sometimes by setting a connection option. The Proton C++ API uses the former approach.
struct your_handler : public proton::messaging_handler {
void on container_start(proton::container& cont) override {
cont.connect("amqps://example.org");
}
};
Here are some Proton C++ examples that address more advanced SSL scenarios:
http://qpid.apache.org/releases/qpid-proton-0.22.0/proton/cpp/examples/ssl.cpp.html
http://qpid.apache.org/releases/qpid-proton-0.22.0/proton/cpp/examples/ssl_client_cert.cpp.html

Using wso2dss as AMQP consumer

I am using RabbitMq as my message queue and I have to use AMQP protocol in my application. I am publishing messages to my queues in RabbitMq and consume the messages using nodejs client. As an enhancement I want to omit the nodejs consumer client and replace it with WSO2 Data Service Server, since currently the nodejs client calls the services hosted on wso2-dss, after fetching them from queue.
I searched a lot and I didn't find proper way to do this without using wso2-esb. I may be able to solve my problem with qpid client, but I really need help.
Please go through https://docs.wso2.com/display/ESB490/RabbitMQ+AMQP+Transport and http://itsmaheeka.blogspot.com/2015/09/esb-490-enhanced-rabbitmq-support.html to get an idea about RabbitMq transport.ESB provides inbuilt RabbitMq transport But for DSS you may have to install required features.
You can directly use the DSS JMS transport[1] to achieve this, because RabbitMQ support JMS.
[1] https://docs.wso2.com/display/DSS350/JMS+Transport

Keeping connection open in Django without websockets

I have a mini computer that does not support websockets that I would like to receive push notifications from a server.
The issue is that after the client connects to the server, the server responds and then closes the connection. This makes it so the client has to continually reconnect to the server to get new information.
Is there a way using Django to allow the connection to be left open and then have the server publish data to the client?
Django is primarily a request/response framework and as such does not have support for real duplex communication.
Socket.IO is the de facto library that makes websocket-like functionality cross-browser (IE5.5+), using real websockets as a transport if the browser allows it, falling back to HTTP long-polling or whatever else if it doesn't. For various options on integrating Socket.IO with Django, read this.

How to implement asynchronous request response in REST based web service

I have a REST based web service system. I need to find a way to support publish/subscribe model here. As you know REST the communication between client and server is HTTP protocol. I use apache (PHP) web server in the backend to server all REST requests. The question is how to use PHP or whatever (in the web server side) to support this kind of Pub/Sub model. One typical scenario would be:
1) Client subscribes for a change in an object (GET /config/object/?type=async)
2) Client does not block with this request as it is async call.
3) Server accept the subscription and waits for the event.
4) Server publishes the client with the required data as and when the event happens.
I basically need to know how to implement all of these four steps above.
You are probably looking for something like PubSubHubbub -
http://code.google.com/apis/pubsubhubbub/
Letting PubSub implement the hub for you means you don't need blocking calls to the server.
They already have implemented example Subscribers and Publishers in different languages.
If haven't already, you should read Roy Fielding's take on the various approaches to PubSub. http://roy.gbiv.com/untangled/2008/paper-tigers-and-hidden-dragons

Secure data transfer over http with custom server

I am pretty new to security aspect of application. I have a C++ window service (server) that listens to a particular port for http requests. The http requests can be made via ajax or C# client. Due to some scope change now we have to secure this communication between the clients and custom server written in C++.
Therefore i am looking for options to secure this communication. Can someone help me out with the possible approaches i can take to achieve this.
Thanks
Dpak
Given that you have an existing HTTP server (non-IIS) and you want to implement HTTPS (which is easy to screw up and hard to get right), you have a couple of options:
Rewrite your server as a COM object, and then put together an IIS webservice that calls your COM object to implement the webservice. With this done, you can then configure IIS to provide your webservice via HTTP and HTTPS.
Install a proxy server (Internet Security and Acceleration Server or Apache with mod_proxy) on the same host as your existing server and setup the proxy server to listen via HTTPS and then reverse proxy the requests to your service.
The second option requires little to no changes to your application; the first option is the better long-term architectural move.
Use HTTPS.
A good toolkit for securing your communication channel is OpenSSL.
That said, even with a toolkit, there are plenty of ways to make mistakes when implementing your security layer that can leave your data open to attack. You should consider using an existing https server and having it forward the requests to your server on the loopback channel.
It's reasonably easy to do this using either OpenSSL or Microsoft's SChannel SSPI interface.
How complex it is for you depends on how you've structured your server. If it's a traditional style BSD sockets 'select' type server then it should be fairly straight forward to take the examples from either OpenSSL or SChannel and get something working pretty quickly.
If you're using a more complex server design (async sockets, IOCP, etc) then it's a bit more work as the examples don't tend to show these things. I wrote an article for Windows Developer Magazine back in 2002 which is available here which shows how to use OpenSSL with async sockets and this code can be used to work with overlapped I/O and IOCP based servers if you need to.