Communicating between two win2k guest Virtual boxes - java

I have not worked much on virtual machines and I need some help in resolving the virtual machine problem. Here is my set up.
I have two linux systems with Virtual Box VB1 and VB2 installed on each one.
Created two guest windows 2000 virtual machines in each of the virtual box.
Configured the ethernet adapter to use Bridge adapter for network connections.
I am running to run a corba server on one of the win2k guest on VB1 and running a client on one of the win2k guest on VB2. On running the client I get connection refused exception. This happens only when I run the server and client on two different virtual boxes.

"Connection refused" simply means that the client cannot open a TCP/IP connection to the server computer. That could be due to any of the following reasons:
The client is trying to connect to a server other than the one you expect
The server is not listening for incoming connections
Windows firewall is blocking incoming connections from the client
There is no TCP/IP connectivity between the machines at all (although it sounds like the DNS lookup happened correctly, otherwise you would have seen a "unknown host" error)
This is a networking issue, so to diagnose it you should try and increase the logging on your client to make sure it's connecting to the right host/port. If that doesn't help, increase the logging on the server to make sure it's listening on the correct port.
Also, if your CORBA application is using insecure IIOP then you could always turn on ethereal sniffing on your client box to see where it's connecting to.

Ok, I myself resolved the issue. The issue was with configuring the virtual machines. I had to use "Bridge Network Adapter" as a NIC card in each of the vm, earlier I was using NAT.. so this solved the problem.

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).

How to connect to a server that may be on the network/the current computer

I may be using my Java program (which is initialized by the simple Batch code at the bottom, which may or may not help anything). From my main computer which will connect to localhost to get to my MySql server.
I otherwise could be connecting via a laptop, which is on the same Wi-Fi network. Therefore, I believe it would use the IPv4 address. Lastly, I could connect via a completely different network and would use my IP.
How could I use Java to detect where exactly it is and change which host it will connect to while pinging the server?
java -jar thb.jar
pause

Client-Server Chat application JAVA

I have a simple java written client and server chat application(with sockets). When running on the same network/computer it works fine. However when i try to run the client from a different network it doesn't connect. I tried using the public IP address of the server to connect the client to the server but without luck. How would I be able to connect to the server app from a different network? any help would be appreciated.
It sounds like you have more of a firewall issue than a problem with the application. Instead of trying to connect with the Java client, first try connecting with Telnet to the server from the same computer, then from the other computer. The first effort will show you what to expect when it works. For instance, if your server is running on port 999, use telnet server.example.com 999.
If the machines are Linux boxes, use iptables -L to see whether there is a block on the port you are trying to access.
If you're still having problems reaching the server, run tcpdump -i tcp:999 on the server host to see what traffic is making it to your server socket, then run the telnet commands again. You should see the tcp connection established when connecting from the local machine, maybe or maybe not when connecting from other machines. If you don't see it while connecting from other machines, run tcpdump there too to make sure the client is definitely sending the traffic to the server.
After you are sure that the server can receive traffic and that your client is sending the traffic, there are no mysteries about what is actually going on and you should find your problem.
It worked after I did port forwarding on router. Most of the ISP provided modem/routers wont let you manipulate ports so had to buy my own modem/router, forwarded the port and worked like a charm. Information on what port forwarding is can be found here : http://www.howtogeek.com/66214/how-to-forward-ports-on-your-router/

How to test broadcast udp packets in Java on the same machine?

Can I perform a UDP broadcast packets on my machine? I don't have a network, i just have my cheap linux box. I want to have a server broadcasting a packet and two or more clients in the same machine receiving them. Is that possible? What IP do I use?
#gravyface gave me hope but I tried: 1) server sending to 127.255.255.255:54321 and clients listenting to 0.0.0.0:54321. 2) server sending to 127.255.255.255:54321 and clients listening to 127.0.0.1:54321. 3) server sending to 127.255.255.255:54321 and clients listening to 127.255.255.255:54321. None of them worked! :(
OBS: I am using REUSE_ADDR and SO_BROADCAST options.
I am able to confirm that 127.255.255.255 works on Linux (Ubuntu) and it does not work on Mac (Snow Leopard). If you ever find out how to do that on Mac let me know. :)
You can use virtual network adapters with different virtual addresses. For example in Windows you can use Microsoft Loopback or TUN/TAP in Linux.
Another solution would be to create an internal network with a Virtualization software such as VirtualBox but this would require a slight faster machine. If you could only afford(since it's a cheap box) a single Virtual Machine you could enable 1-4 network adapters that would allow you to bind your different UDP clients individually on each one of the virtual adapters of your virtual device.

BACNet plugin for Building Management System

I'm trying to get a BACNet scanner up on an Seimens server running the Apogee system with a BACNet interface. I've tried using BACNet4j put i get a port bind error on the LocalDevice object for test/Scan.java.
Does anyone know of any other libraries I could use or a reference to instructions for setting up a BACNet plugin to a building management system?
I have had the same problem before, i.e. the BACnet client needs to both send and receive from UDP port 47808. Since the BACnet server already uses that port to listen (and reply) my solution was to use a virtual IP (a bridge) so that my client runs on the same Ethernet card but with a different IP address. A bit convoluted, I know, but it works.
Whether or not the Apogee system supports virtual (or simply additional) network drivers is another question altogether. On my Linux and Windows machines I can run as many servers and clients as I need (I actually don't know what is the limit, I have run up to 5 servers and 3 clients without any problems).
Concerning the port bind error, you may have to configure your firewall because:
BACnet/IP is using UDP
the default port number is 47808 (0xBAC0)
Your issue might be the use of a (BACnet port #) socket that is already in-use; you have to ensure that it's not in exclusive-use - before binding to the socket, but also (slightly more) important, also ensure it's marked for reuse.
But unless you're listening for Who-Is broadcasts, I'd recommend listening for the (unicast) responses upon a different port #, e.g. 0xBAC1/47809, but still send upon the standard port # 0xBAC0/47808.

Categories