GAE: MQTT broker - java

So I was wondering if it's possible to run a MQTT broker on the Google App Engine platform?
Couldn't find any information about it (or maybe I might be using the wrong keywords).
I've got my GAE running on Java so I'd like to go into direction of running the MQTT broker on GAE using a backend.
EDIT:
Did some further research and it seems Moquette is running on Java. Does someone have experience running Moquette on the GAE?
EDIT2:
Ok, it seems the examples of Moquette are running using an OSGi container, which is unavailble in GAE. Looking for a script to start this server on GAE.

MQTT is protocol on top of TCP. In order to run MQTT server, one needs to be able to open a listening socket. Those are still not supported on normal AppEngine instances.
Note: GAE backends have been replaced: now you just have automatic scaled (aka frontend) instances and manual scaled (aka backend) instances.
Back to your problem: Managed VMs have most of the benefits of GAE (access to services), but run a full JVM, which allows listening sockets.

An alternative to Moquette would also be the HiveMQ broker, it also runs on Java and can be easily installed. All the documentation is available here.
We haven't tested it on GAE yet, but if you have any problems running it, you could ask in the support forum.
Update: If Peter Knego is right, then HiveMQ or any other MQTT broker won't work on GAE.
Full disclose: I'm working for the company, who develops HiveMQ.
Cheers,
Christian

#Peter Knego is definitely right, and all i would add to his answer is that,
If you manage to configure you application to use a custom Runtime on the Managed Vms of Appengine and Compute Engine,
then you will be able to run you MQTT brooker perfectly sound and well.
As long as you define a fire wall to allow a tcp connection at the port which your broker is listening from.
By default the ports are blocked for security reasons.

Related

is there a way to use JMS (java message service) on ESP32?

I'm trying to build an application in which I want to use the JMS (java message service). Unfortunately, I'm unable to find any libraries specifically for ESM32-WROOM online. So, can anyone help me with how can I build the JMS stack for ESM32-WROOM on my own if it's possible!. In my application, the ESP32-WROOM will get messages from the server every second.
As noted in your question, JMS is the Java Message Service so in order to use it you'd need to use Java which would require a Java Virtual Machine (i.e. JVM). The JVM is a sophisticated piece of software which is almost certainly not supported on ESP32.
Most JMS providers also support other protocols for IoT devices like ESP32. For example, ActiveMQ Artemis supports JMS as well as MQTT (among other protocols). MQTT is a protocol specifically created for small sensors and mobile devices. It is optimized for high-latency or unreliable networks which makes it a good fit for IoT devices. I recommend you use MQTT on your device if possible. Take a look at the ESP32 MQTT Library.

Manage Topics on Mosquitto

I want to develop a simple push notification system for various android devices.
After two days of documentation i've found very interesting to use MQTT protocol.
System needs:
- an MQTT client on Android: eclipse Paho seems to be a good solution
- any MQTT broker you like for the server part: my attention is on Mosquitto cause is Open-Source
I've read documentation and the configuration file and seemed clear. The only thing that I couldn't understand is if i can manage topics (where clients subscribe to). In particular if i can create topics and how to.
Thanks.
It's not clear whether you mean on the client side or the broker side...
Assuming you mean the broker side, you don't need to create topics, they are created automatically as needed. You can control what clients have access to what topics using the built in authentication and ACL code, or you could use an authentication and access plugin. Writing your own is quite easy, or you could use the excellent https://github.com/jpmens/mosquitto-auth-plug
On the client side, simply subscribing or publishing to a topic is sufficient to create it on the broker, assuming you have permissions for that topic. This may not be the case in all MQTT implementations.
As an example, try subscribing to the # topic on test.mosquitto.org or iot.eclipse.org. These show a huge range of available topics and there is no admin to support them in the background.
This basically means that the only administrative load you have is restricting access on the broker where required.
Using code stole from somewhere, I made a pretty simple "MQTTMessenger" app for Android. https://bitbucket.org/mjgasner/mqttmessenger
From what I remember, you'll need to go into src/com/gasner/mqttmessenger/MessengerService.java
and change the host ip to the ip of your MQTT server.
For the MQTT server, I used Mossquitto server.
You'll also have to make sure you port forward port 1883 to the server.
I used this to send stock numbers to my phone. It's been almost 2 years ago, otherwise I could tell you more.
The C2DM directory is unrelated. It is Google's push notification service that I was also playing with at the time.
In the other directories at Bitbucket https://bitbucket.org/mjgasner are the .NET service and winforms app I wrote to communicate with the MQTT server. The service would accept the message from the android app through the server and reply with the stock amount it pulled from google's api.
If you have any more questions, comment below.

ZeroMQ PUB/SUB not working on same machine on different JVM

I am using Zero MQ PUB/SUB model where PUB and SUB are two different applications deployed on the same machine on webpshere 6.1. This model works fine on my local machine but when I deploy it on a remote unix box server it isn't working. My SUB never receives a message from PUB. I tried all the options suggested i could find on the web (localhost, 127.0.0.1) but no luck. Appreciate any help on this. I am using jeroMq 3.2.2.
Thanks
Akash
If you're using multicast, then you need to enable loopback on the socket. As a result of this, the sender app will get the data as well if it's listening for it.
We also faced same issue and it was fixed by using below settings:
Publisher side use * (star) : tcp:// *.port number
Subscriber side use machine name : tcp://machine name of publisher.port number

Is any one using GAE for Nat traversal? (as server for keeping mappings)

So I can limit my app with UPNP NATs capable clients. I would love to see any Opensource Java project using GAE as server for keeping maps like (ClientID, IP:PORT) (with example of some on clients simple hole puncher) Is there any such project?
Why not just stay with http transport, which usually works well with firewalls (otherwise users complain).
As long as you have the clients call you in the cloud, it should work well.

Java Socks5 External Application

I have connected to a socks5 server in my java application, and now I want to launch an external application and have all of its connections run through the socks5 server. The external application itself doesn't support socks5.
Any input would be great, scratching my head here..
The 2 trick I know how to do that are to replace the standard runtime library or a similar trick to intercept the OS networking calls or to setup a set of finely tuned firewall rules in the kernel.
Both of these techniques are very OS specific and have no way to da that using java.
Your best bet would be to run an existing socks5 wrapper and let that program start the external application like socksify.
I have had mixed experience with this approach, some applications work, others do not, and never found any logic in it.
YMMV
Another approach is to play a tcpproxy in the Java application (e.g. using the Apache MINA stuff) and have the application connect to your proxy port on localhost. Again this will only work for certain services.
If the external application is written in Java it does support SOCKS. Just run it with -DsocksProxyHost=host and -DsocksProxyPort=port. See [1].
[1]: http://download.oracle.com/javase/6/docs/technotes/guides/net/properties.html "Networking Properties".

Categories

Resources