Testing a client/server Java application on a virtual machine using VirtualBox - java

I'm testing a client-server based Java application where a specific scenario involves having both the client and server running on the same host (i.e., the client connects to the server running on localhost). This seems to work fine except for when I test this scenario on a virtual machine (running 32bit Windows 7) using VirtualBox.
Note: Everything henceforth is running inside the virtual machine. I start the server and try to connect to it using the client but the connection times out. Surprisingly, I tried connecting to the server using putty and the connection behaved as expected. Both the Java client and putty tried to connect to localhost - the client failed but putty succeeded.
Does anyone have a possible explanation for why this might be happening?
Note: This is not a duplicate of Addressing localhost from a virtualbox virtual machine

How do you connect to the localhost? By connecting to the hostname "localhost"? You could try connecting to the InetAddress returned by getLocalHost()

Related

How to connect remotely via tcp to the h2 database?

I am trying to start H2 in server mode to connect an application from another computer. But no matter how hard I have tried, I have not succeeded.
I have seen the documentation and to start the server from the command line is executed:
java -cp h2-2.1.214.jar org.h2.tools.Server -tcpAllowOthers
output:
TCP server running at tcp://127.0.1.1:9092 (others can connect)
PG server running at pg://127.0.1.1:5435 (only local connections)
Web Console server running at https://127.0.1.1:8082 (others can connect)
now from the other pc, as I understand I must execute the connection in the following way:
jdbc:h2:tcp://[server][:port]/[path]/[databaseName]
then it should be:
jdbc:h2:tcp://127.0.1.1:9092/home/mateo/database
But I have read that 127.0.1.1 only works locally. I have also noticed that when I open H2 Console in the examples I have seen, the machine's ip appears, that is to say: 192.168.X.
What am I doing wrong?
(Update)
I am currently using Linux.
I have launched the server from Windows and managed to connect it from Linux successfully following the above steps. But, I still don't understand why it doesn't work in Linux, in Windows it loads the server with the IP address of the machine. It makes me think that I have to do some additional configuration for Linux.
server running
You need to replace local IP address in your JDBC URL with real non-local IP address of your server (jdbc:h2:tcp://127.0.1.1:9092/*** -> jdbc:h2:tcp://192.168.1.4:9092/***, for example). H2 listens all network interfaces of the host, it doesn't matter which address was reported in “runnig at …” message.
You also may need to protect ports 8082 and 9092 from connections from untrusted systems if you have them in your internal network and from connections from external network (make sure your router or whatever you have doesn't redirect connections to the host with database server).

Hosting Java Server on LInux Virtual Machine

I am trying to host a Java server on Linux (Ubuntu 13) virtual machine on VirtualBox. I have to connect a client locally to the server via sockets. I am having trouble setting up the ip address and port for the client to find the server socket on the virtual machine.
you should get the IP address on the VM
then ping the IP address from your CMD, if it's ok, then trying to run Java program, if not, you should focus on the VM configuration.
About your code, you can always run a Java socket server just on Windows and using a Java client to connect, after successfully test the code. You can launch the server code in VM.

Cannot connect to couchbase server

I cannot connect to a couchbase server that runs on a different computer of the same local network.
The machine has the IP address 192.168.1.150. I use the official hello-couchbase tutorial for the Java SDK. Thus, my code looks like this:
Cluster cluster = CouchbaseCluster.create("192.168.1.150");
Bucket bucket = cluster.openBucket();
The second line triggers:
com.couchbase.client.deps.io.netty.channel.ConnectTimeoutException: connection timed out: /192.168.1.150:11210
Is there any way to narrow down the reason for the connection failure? The webclient on localhost:8091 (in a browser of the remote machine) tells me that the server is running.
This sounds like a problem with a firewall. Can you telnet from your client machine to the Couchbase server on port 11210? From a command prompt, type telnet 192.168.1.150 11210
If you see a blinking cursor, the test succeeded and the firewall is likely not a problem. You may need to install a telnet client if it isn't already available. Windows Telnet installation: http://www.wikihow.com/Activate-Telnet-in-Windows-7

ServerSocket in Java application running in Azure Virtual Machine with Ubuntu?

I've created an Ubuntu Virtual Machine in Microsoft Azure and uploaded a Java application which uses a java.net.ServerSocket to handle incoming messages I send - with java.net.Socket - to port 20000. This application works perfectly in any machines, but it can't receive any connections when running in Azure VM.
I realized that the VM won't answer for pings and traceroutes, but I can connect to it using SSH (PuTTY) and also send files using PSCP. I've already configured endpoints on Azure - with the public and private ports (20000). I also tried to disable firewalls on VM, but never successfully. VM isn't reachable.
What more can I try? Thanks in advance.

connect remote MQ using Java?

Friends,
I installed IBM explorer 7.1 which have server and GUI. Locally I connected the queue using inter process communication. Now I need to connect the server QM from remote machine using java standalone program.
In server I have created a queue, port and server channel. when I trying to connect using host name , unable to get the connection. Is this the right way?. else I have to install client where I tried connect that server.but getting error code 2035 when i run that java program. listener and queue manage is running in remote machine. Some forum i seen that AMQCLCHL.TAB file using for client connection. I had confusion whether i have to use that for client connection. if yes how i can use that?

Categories