Java sockets server, on a clustered server - java

I've a question which may seem strange, but I'm working in a environment which has very restricted options.
Basically, I've a job which runs on a SAP Netweaver server, which is clustered.
This job runs socket server code, which allows an ancient system to communicate with it.
My question is this:
Depending on which side of the cluster the job runs on (and I can't influence this), the sock server will either run on a .127 IP or a .129 IP.
Since the connecting system needs a fixed IP to connect to, It gives me a problem.
So, can I open the socket on the .127 IP each time, regardless of which of the two IP the Job happens to be running on, or does it have to be opened on the same IP that the code is actually running on ?

Well, if you can't influence the server, you can introduce a component between the ancient system and the cluster that will redirect the request to one of the IPs in the cluster (.127 / .129 in your example).
|-> [IP .127]
[ancient system] --> [load balancing/proxy component] |
|-> [IP .129]
An actual implementation can vary, basically it boils down to hardware based solution or software based solution.
Hardware
Some network equipment, like load balancers provide this feature, so talk to your network department about this, they'll provide a couple of options.
Software
You can install solutions like "ha-proxy" that will solve this at the level of software

Related

How to find the TCP/UDP port used by a specific process on a given remote machine

I have an issue I can't manage to solve.
What I know :
Some information about the process I'm looking for : It's a java process but if I have access to information similar to what's in ps -ef | grep java, then I can find it's PID.
The IP address of a remote machine running Linux version 3.16.7-35-desktop (SUSE Linux)
I would like to find the port used by that process on that machine, with some constraints :
Must be done programmatically, in java
Must work from Windows and Linux (if needed, the java code could handle both cases separately)
Doesn't require to install any other application (neither on the caller machine nor on the remote one)
I also know the port should be between 10000 and 20000. I have network access to the remote machine (both machines are on the same subnet).
How would you do that ?
Note : I found this, but it's old and not remote.
This is a standard hacking requirement. You can do do what nmap does.
Connect to every port in the range in turn and try to determine which the service is this listens to or responds to that port based on the data you get from the service as you connect. It is very slow and will look like a hack if you have any tools to detect this, but it is a technique which has been in use for a long time as it is the only way to do this without a service to tell you what is running on that machine.
A much better approach is to have a service discover process somewhere which has all the services you can contact, ideally with their status so you can easily find one which is available to your client.

RabbitMQ connecting VM to Host

I'm new-ish to networking, and I'm swimming (drowning) in semantics.
I have a VM which runs a Java application. Ideally, it would be fed inputs from the host through a RabbitMQ queue. The Java application would then place the results on another RabbitMQ queue on a different port where it will be used by the host application. After researching it for a bit, it seems like RabbitMQ only exists in the localhost space with listeners on different ports, am I correct in this?
Do I need 2 RabbitMQ servers running in tandem, then, (one on the VM and other on Host) each listening to the same port? Or do I just need one RabbitMQ server running while both applications are pointed to the same IP Address/Port?
Also, I have also read that you cannot connect as 'guest/guest' unless it is on localhost, which I understand, but how is RabbitMQ supposed to be configured/reachable to anything besides localhost?
I've been researching for several hours, but the documentation does not point to a direct answer/how-to guide. Perhaps it is my lack of network experience. If anyone could elaborate on these questions or point me to some articles/helpful guides, I would be much obliged.
P.S. -- I don't even know what code to display to give context. Let me know and I'll edit the code into the post.
RabbitMQ listens to TCP port 5672 on all network interfaces out-of-the-box. This includes the "loopback" interface (to allow fast connections to self) and interfaces visible to other remote hosts (including VMs).
For your use case, you probably need a single RabbitMQ instance for both directions. The application on the host will publish messages to one queue and the Java application in the VM will consume messages from that queue and push the result to a second queue. This second queue can be consumed by the application on the host.
For the user, you need to create a new user with the appropriate rights. This is documented in the access control article. To create the user, you can do it from the management web UI (after you enabled the management plugin) or using the rabbitmqctl command line tool.
The last part is networking between the host and the VM. It really depends on the technology you use. It may work out-of-the-box or you may have to configure how VMs are connected to the network. Refer to the documentation of your hypervisor.

unreliable behaviour of Openfire server at EC2

We are using openfire server 3.7.1 on Amazon Ec2 linux instance for a chat Application.
Currently, we are in initial development stage, where we are testing it with 4 or 5 concurrent users.
Now, and then we are getting issues with openfire server:
1) Java heap space exceptions.
2) java.net.BindException: Address already in use
3) they both lead to 5222 port not listening, while openfire admin console at 9090 is working fine
Eventually when i stop all openfire processes and then restart it, again it goes to normal.
I want to know, whether this is a bug in openfire version 3.7.1 or EC2 have some issues with opening of port 5222. I am really apprehensive about performance of Openfire server when 1000s user will be using it concurrently?
Solved by:
Disabling PEP.
Increasing Openfire JVM parametres
The Java heap space exception is common to Openfire, you can check your JVM arguments and increase the parameters. In my experience there were a couple of cases that caused those:
clients using Empathy.
some plugin that provided buddy lists/ white/black lists etc (had to do something with the user's roster lists).
You need to make sure port 5222 and 5223 are opened (some clients may use the old SSL port) in EC2 Firewall settings.
If you plan to have thousands of users, I suggest you get static IP address (you don't mention what's your current config). Also checkout jabberd - proved to be more reliable than openfire.
1000s of concurrent users should not be a problem for Openfire at all. It has seen 250K in testing. It will always be determinant though on what the users are doing.
There is a known memory leak in Openfire that has been fixed but not yet released. It is related to PEP, which can be shut off to circumvent this issue if that is feasible for you.

How to stop routers blocking my applications network traffic

I have a application which listens for commands over IP.
The program works fine locally but when I try to send the application commands with a remote address it won't connect.
Is there anyway to get around the router blocking the inbound network traffic?
I'm using JAVA
Thanks.
If this is a pair of hosts you control, you can open the incoming port. You might also
succeed using a tunneling program such as Hamachi to effectively set up a VPN linking
the hosts.
If you're talking about a pair of unrelated computers (for example trying to set up
a connection for a game) there's no general solution that doesn't involve installing
and trusting additional software. The usual solution is to use a public server and
relay the traffic between the end points.

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