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".
Related
I have a java jar running on windows server 2012 r2. I have created a task to run this jar on every restart of the server. Now, I need to restart the application whenever its stopped because of some reason. So I should find a way to find the status of the application.
A typical way to handle problems of this sort is with a service wrapper application, of which there are many, each with particular features. Popular examples include
Tanuki, YAJSW, and Procrun, among others. These wrappers have built-in facilities to monitor and keep alive the applications they govern.
If you just want to check whether the application is running, then a common approach is to send probes to some TCP port that it exposes. Many applications open a port specifically for this purpose.
I am looking for an approach to create a java application for web socket. This application should not use any server's jars.
I say this because I have seen that java client for web sockets are available only for server to server communication. If I need to create it outside the server I have no other go to get those server's jars imported inside.
nv-websocket-client is a new WebSocket client library written in Java. It requires just Java SE 1.5, so it can run even on Android. The size of nv-websocket-client-1.3.jar (released on 2015-05-06) is 62,854 bytes and it does not require any external dependencies. See "WebSocket client library (Java SE 1.5+, Android)" for details.
I'm not sure I understand your question completely but from what I can gather of your question you might want to look into just plain old sockets. It uses a simple tcp protocol to talk between Java applications and is supported natively in Java take a look at this example (http://cs.lmu.edu/~ray/notes/javanetexamples/). Another alternative for server to server communication is to use something like RabbitMQ (http://www.rabbitmq.com/) or Kafka (http://kafka.apache.org/) but those require much more setup and are more complex then sockets.
You are asking for java, however I suggest you cast your net wider and dive into using Node.js (javascript) as your web socket client/server ... nodejs applications run outside the browser and offer super fast asynchronous networking using the V8 c++ javascript engine ... the same engine which lives at the heart of google's chrome browser ... think of it as the JVM for javascript ... you write javascript yet it executes at c++ speeds
To build a socket application you need only a server part where you instantiate a java.net.ServerSocket and a client part where you instantiate a java.net.Socket.
To do that is not necessary any special library.
Those are standard java applications (with a public static void main(String[] args) method) so you don't need a server environment (servlet container or Java EE container).
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.
I want to connect my android application to an applet which is running on my pc on Google chrome on Wi-fi.. where my phone works as a wi-fi hotspot and pc as the connected device. I want the connection to work uniquely as I want commands to be passed from my application to the specific applet, on the execution of which my applet does specific tasks. Please tell me the APIs which I can look in both Java and Android or the technology I have to use to make it work..
You need to use any program, such as wamp server, to make your computer to be a localserver. It will install PHP 5, MySQL and Apache. In other hand, you will also need a little bit of knowledge in Php language to create you own web services.
Another thing you need to be aware is that to handle you connection between server and device (and by this I mean which IP you are going to use) you will have a little headache; but first things first..break your problem in little parts thus will be easier to solve them.
I recommend this tutorial.
I think the simple way to connect these two softwares is using UDP.
It is fast, it is easy to program but it is generally unreliable according to TCP. But it is already local network. I dont think that is a case you need to take care in your local wifi network.
So take a look at this tutorial http://tutorials.jenkov.com/java-networking/udp-datagram-sockets.html
There are other ways like https://www.alljoyn.org/. It has more functinality but more complicated.
You must install Server on your PC(Apache httpd or apache tomcat or other based on your interest). A server listens to request from clients. When your mobile is connected to your pc(doesn't matter wire or wireless), you can make a request to an url(say, localhost:8080/welcome) from your app.
Create an applet and connect it with your web application(in the server) using java.net.URL and java.net.URLConnection.
On performing some operation on the client, call the url of the server application and forward the response to the applet.
I'm a BSc student in CIT. I have a project in which I want to use a Java applet and JDBC in a sort of host/client.
My applet is working properly on localhost, but when I deploy it on apache webserver I loose the JDBC connection.
Questions:
Is it possible to use an applet with JSBC?
If yes how to do it?
Is there any web server in which to deploy applet and that supports jdbc connection?
My system: Fedora 8, NetBeans 6.5, XAMPP, MySQL.
You're probably running up against an issue with the Applet running in a sandbox, it can only communicate with the server from which it came - so if your database is on a different machine it can't be found.
A preferable architectural approach is to have your server do all the JDBC and communicate the information requested via HTTP to the client which is thinner dealing mainly presenting the user interface.
Yes its possible to use applet with jdbc.
Look here and here and here for possible ways of implementation.
Try googling for webservers, you will find tons of them, one lead is http://eatj.com/.
Rgds,
Aeon