Java/Jmeter connect timeout but not on browser (Not a JMeter issue) - java

In windows 2003 using JDK 1.7_21
So I setup Jemeter on my desktop to do an HTTP request to a specific URL and it works fine. But when I try from another machine I get a connect timeout.
The URL works fine in the I.E browser and I can also ping the domain from the command line. But for wahat ever reason the JVM doesn't want to connect.
In fact this is to test a sample HTTPClient I wrote. it's not the code because the code works off the desktop but on the server environment the JVM wont connect, proof JMeter wont either. but the browser and pings works.
I suspect java is getting it's network settings from somewhere different??? Proxy???

Well.. is IE/Windows using a proxy? You can check by going to to Internet Options > Connections > LAN Settings
If it is, you can set some JVM properties so that your Java application uses a proxy, there a couple ways of doing that, one way is through the command line when you execute it, you can use something similar to:
java -Dhttp.proxyHost=your.proxy -Dhttp.proxyPort=your.proxy.port -jar your.jar
or
java -Dhttp.proxyHost=your.proxy -Dhttp.proxyPort=your.proxy.port YourMainClass

Related

Not able to record in Jmeter after OS reinstallation

I am using Jmeter 2.13 version and with that I used to record many scripts earlier successfully without any issue . Now, my OS has been reinstalled and I am holding Windows 8.1 , 64 bit version.After re installation, I am not able to record HTTPS web applications even though my proxy configuration is correct. After I setup everything in Jmeter, and click on start from work bench and I navigate to the browser try to access the application, it shows "Server not found" message.
However, the scripts which I saved earlier are working fine without any issues. only the new recording is not working.
Help me with the possible solutions.
"Server not found" indicates that browser is unable to access Internet (or intranet).
Most likely you're sitting behind the corporate proxy server and in previous JMeter installation you had these proxy server details specified in system.properties file like:
http.proxyHost=10.20.30.40
http.proxyPort=3128
https.proxyHost=10.20.30.40
https.proxyPort=3128
Double check with your network administrator if this is the case, if yes - take steps from Using JMeter behind a proxy User Manual chapter.
You can also try out JMeter Chrome Extension as an alternative solution - in that case you don't have to worry about proxies and SSL certificates substitution.

Is it possible to run java command line app from python in AWS EC2?

I am working on some machine learning for chemical modelling in python. I need to run a java app (from command line through python subprocess.call) and a python webserver. Is this possible on AWS EC2?
I currently have this setup running on my mac but I am curious on how to set it up on aws.
Thanks in advance!
Since you're just making a command line call to the Java app, the path of least resistance would just be to make that call from another server using ssh. You can easily adapt the command you've been using with subprocess.call to use ssh -- more or less, subprocess.call(['ssh', '{user}#{server}', command]) (although have fun figuring out the quotation marks). As an aside on those lines, I usually find using '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' stabilizes scripted SSH calls in my environment.
The more involved thing will be setting up the environments to properly run the components you need. You'll need to set up ssh configs so that your django app can ssh over and set up -- probably with private key verification. Then, you'll need to make sure that your EC2 security groups are set up to allow the ssh access to your java server on port 22, where sshd listens by default.
None of this is that hairy, but all the same, it might be stabler to just wrap your Java service in a HTTP server that your Django app can hit. Anyway, hope this is helpful.

How do I set a proxy after runtime

I am making a Minecraft mod, and I need to be able to make the JVM use a proxy while sending all the packets to the Minecraft servers and what-not. I basically need to be able to set the http.proxyHost and http.proxyPort arguments at any time that I need to.
I have not come here empty handed, and I have tried multiple things, one of these being just using System.setProperty like this:
System.setProperty("http.proxyHost", getProxyHost());
System.setProperty("http.proxyPort", getProxyPort());
But to no avail, my real IP was still being used to connect.
I also tried to set https proxy information just like the code shown above, but with https instead of http.
I know that the proxies work, and that this is possible, because I used this batch file to run Minecraft, and the proxies worked perfectly:
java -Dhttp.proxyHost=<host> -Dhttp.proxyPort=<port> -Dhttps.proxyHost=<host> -Dhttps.proxyPort=<port> -Xmx800m -jar Minecraft.exe
Whenever connecting to a server after running minecraft like shown above, the server console and just anything to do with my IP was now using the proxy, now before you go asking Well why don't you just use the batch file to run your Minecraft with a proxy?
Know that I want to be able to change this at any point, without having to turn off Minecraft, and then turn it back on, I want to be able to have a menu where I can just input the proxy host and proxy port and then be able to use that.
Thank you for any help that you may give me.

javasocketbridge - client not reading / java.net.SocketPermission

I am trying to achieve a TCP connection between a JavaScript client and a java server. (implementation must be this way I cannot swap to node for the server for example ).
Web sockets implmentation in java looked very complicated. I had a look at Jetty and JWebSocket and was quickly scared off. I have no idea what is going on in the source for them. – So I didn’t have much luck implementing a server using them.
So then I looked for websocket alternatives.
I noticed SocketBridge, It seems very straight forwards and offers exactly what I need for my project so I downloaded that.
I created a simple java server that just prints what I receives and sends a string as bytes back. I used the prebuilt JavaSocketBridge and modified the index.html to point to my server. My server recived the message but nothing showed up on the client.
function run(){
socket_connect('localhost', 31113);
socket_send("Hello from JavaSocketBridge applet");
}
I then decided to build the JavaSocketBridge to see if I could debug the read methods. However my build of JavaSocketBridge refuses to connect with the error.
Java Socket Bridge ERROR: Could not connect to localhost on port 31113
Access denied (“java.net.SocketPermission” “127.0.0.1:31113” “connect,resolve” )
(This was in chrome but it happens in firefox too)
So my questions:
Why does my build get a socket permission error?
Why does the client not receive anything even though the example does from google.com:80?
Notes.
My server appears to be working fine. (I have used a simple java client to test it.
I have used java 1.6 and 1.7 to build the JavaSocketBridge)
I have included C:\Program Files\Java\jre7\lib\plugin.jar
My System is Win7 64 and java SDK / JRE is up to date
Edit. Ive gone back to jetty and got a client/server working, however I will monitor this question.

JMX : cant connect from Windows box to monitor JMX port on a Linux system

I have a lot of experience with jconsole.exe and JVisualVM.exe , in the JDK1.6 and have connected thousands of times from a Windows JVM over to a Windows JVM on another machine via JMX.remote but it fails when I try to monitor a java instance that is running on a Linux host (from a Windows host and I tried JMX listener on redhat and SUSE at Amazon EC2). I also tried using jconsole.exe and get a similar error.
Is there any reason anyone can think of , why this kind of JMX connection would have a problem. Any ideas I can try? Has anyone "actually" done this and can say it will work if I persevere?
The error I get from JVisualVM (on the remote connect attempt) is something like this:
"Cannot connect using service:jmx:rmi:///jndi/rmi://<jmx service ip>:8001/jmxrmi"
My remote JMX service config is like this:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8001
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.hostname=<jmx service ip>
Found a similar question at this link but it didn't answer my question.
I verified that "iptables" is not enabled as a service and is not on and so I don't imaging there is any sort of firewall blockage. Also, both the windows and linux machine are on a 10.0.0.0 private internal subnet together. I am able to telnet into the port 8001 to verify its there , and its listening (netstat -ap) on the linux machine.
See the system property java.rmi.server.hostname. On your Linux server JVM, set this system property to be the public IP of the host. Then use the public IP in you client JMX URL.
I think your problem is that the RMI implementation is kind of hard to work with through firewalls and such as it requires more than the port you specify to work. Things you typically wouldn't notice if you connect to your own machine or a machine on the same network.
This post describes the problems you will run into quite well
If I were you, I would try to setup jmxmp as an alternative protocol. To do so you need to add the jmxremote_optional.jar (free from Oracle, download "JMX Remote API 1.0.1_04 Reference Implementation" from here) to both the server and the jvisualvm classpath but it is worth it.
If you google for jmxmp you will find quite a few examples on how to set things up, one of my first hits are http://pub.admc.com/howtos/jmx/distributed-chapt.html#jmxmp-sect which may be a bit too code oriented but I add it here anyway because it explains the things like like most with jmxmp in a few good sentences.
How to define the server side endpoint is depending on what you are running. Most app servers will let you type in a jmxmp enabled jmx service url but if the server is written from scratch you might have to set it up yourself in code instead of using the -D switches to java you are used to.
Give it a try and return with more specific questions about it if you run into problems.
Edit:
After you have added the jar to the classpath, the only thing you have to do in your code (assuming you are not using a server app that already handles it for you) is the following (omitting declarations, exception handling and such as you will figure it out anyway):
url=new JMXServiceURL(jmxurl);
this.server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, ManagementFactory.getPlatformMBeanServer());
this.server.start();
Have you tried creating an SSH tunnel to the Linux box from your Windows machine? http://oldsite.precedence.co.uk/nc/putty.html
Or if you have cygwin, just try ssh -f your-user#remote-server.com -L 7777:remote-server.com:123 -N where 7777 is the port on YOUR windows machine, and 123 is the port on the remote Linux box that listens to JMX commands.
With either of the above, you can use jconsole or visualvm on your Windows box and connect to localhost:7777.
I know iptables is disabled, but just confirm that JMX is working fine at that port by SSHing into the Linux box and trying to use commandline JMX mode of jconsole for localhost (on the Linux box).
I have actually just tackled this problem myself and figured it out.
I would wager that the problem is the RMI connections - you can't predict which ports it will use and so you can't get it to work with a firewall.
The workaround is to use an SSH proxy:
SSH to the box where your application is running but use the -D option like this:
ssh user#remoteHost -D 9999
As you are on Windows, you can use Cygwin to run the command above, or you can do the same thing with Putty through the GUI (guide here: http://blog.ashurex.com/2012/03/15/creating-ssh-proxy-tunnel-putty/)
This will start a socks proxy on your local machine on port 9999.
Open JVisualVM and in the preferences, under 'network' configure it to use a socks proxy at localhost, on port 9999.
If you do the above, you should then be able to connect to the remote machine as normal and since all the RMI traffic is now going over the SSH proxy, it is punched through the firewall and works nicely.
Good luck :-)

Categories

Resources