Port specific RMI application - rmi

Question :
How do I make my RMI application to be IP and Port specific ?
It means I want that when my application initializes then it'll ask for port and root systems IP address and a port where application could execute independently

Apart from the part where you ask the user for the data, in an RMI client this is just a matter of building the lookup string for Naming.lookup() dynamically instead of statically: e.g. instead of
MyRemote mr = (MyRemote)Naming.lookup("rmi://somehost:someport/MyRemote")
you would have
String host; // initialized by dialogue with user
int port; // initialized by dialogue with user
MyRemote mr = (MyRemote)Naming.lookup("rmi://"+host+":"+port+"/MyRemote")
At the RMI server end, the port number is provided to super() when constructing your remote object, if you extend UnicastRemoteObject, otherwise to UnicastRemoteObject.exportObject() if you don't extend UnicastRemoteObject. Normally you don't need to specify your own host at all; an exception is if you are behind a NAT device or some other form of port-forwarding firewall, in which case you need to specify the host in the java.rmi.server.hostname property in the server JVM, before you export any remote objects (including the Registry).

Related

How to access my local [WAMP] webserver from outside the LAN?

I am trying to access my local [WAMP] webserver from any remote devide. I am so far able to access it from a device inside the LAN, but fail to do so from outside it. As far as i know, port forwarding is how we achieve this. But currently unable to do that correctly.
Present error when trying to connect :
Some of the articles which i have followed so far are:
general-port-forwarding-guide
how-can-i-access-my-server-from-outside-of-my-lan
how-to-expose-a-local-development-server-to-the-internet
The main steps which i follow are as follows:
Make sure server is accessible inside LAN.
Open router's port forwarding settings and port forward the set static ip address (in step 1). Set port 80 and 8080 for communicating.
Access the server via my public ip (can check public ip and if forwarded port is accessible from here)
This is a temporary solution for testing purposes only with 8 hour server connection duration time limit (and a limited no. of server connections):
access_local_server_remotely_for-Development-And-Testing-Only and here is a video guide about how to use it.

Public access container in QNAP NAS server

I have running node.js app in my docker container in Container Station in my QNAP NAS. It's working on my local network on the port I have specified.
Typically I would set reverse proxy pointing fe. my-domain.com/my-app :80 => :<local-port>
On NAS I have static IP provided, I have even a domain for public access (my-server.myqnapcloud.com) and I'd like to set up somehow my server to be visible outside. It doesn't have to be QNAP domain, I can set my own domain pointing to QNAP local address, but still I'm not able to forward local port to another in server scope.
What is the best way to setup such enviroment? It seems to be much easier without NAS at all...
If i'm not wrong, your QNAP server is over the router. If so, you have to change some settings...
Steps to do:
Open a Container Station and find the instance of your container.
Go to "Settings" then "Advanced settings" and find LAN bookmark (sieć)
There must be a grid: "Port Routing" with 2 columns: "Host" and "Container".
"Container" - a port on which container is listening incoming internal connections
"Host" - a port on which QNAP server is listening incoming external connections. You have to remeber this value!
Close Container Station and open myQNAPcloud application
If you don't see the service which is responsible for port forwarding, you have to add appropriate service.
After that you have to execute changes in a router.
Note:
I've struggled with the configuration of PostgreSQL database installed on container. Finally, i was able to achieve that. Here is detailed description: How to enable remote connections to your PostgreSQL server (in Container Station) on QNAP NAT server over the router
Hope this help.

Static Way to Access a Remote Machine

There's an application. This application is run on several different client devices and it makes use of a server: that is, each of those instances of the application may connect to a server, said server being a certain remote machine that is constantly listening for incoming connections, at which point the client machine and the server machine communicate following a certain protocol.
Now, this is all nice and easy as long as I'm testing within one LAN managed by one router. I can simply set the server machine to have a static IP address and this address will just be hardcoded into the application so that every instance of it will be able to directly communicate with the server endpoint. But what I'm not sure about is what I'd do if this application was intended to run outside the limits of a single LAN with private IP addresses.
Basically, my question is what approach should I choose in order to have a static way to access a specific remote machine.
Is there any static public address that can be used to reach it? Or should I purchase a domain name and have it respond to requests from clients with the server machine's current public IP address? Or should I go on and purchase a static external IP address? Or am I simply not thinking about this the right way, and the solution should be approached from an entirely different direction?

How to create a socket connection over nat from public end

I feel this question is best started with a simplified version of the scenario.
Server A is connected to the public internet.
Server B is in a private Network and uses network address translation to connect to the internet.
I own both servers and can edit the software on them.
The ip addresses of the servers and the nat router are known to me.
Using Winsock, I need to create a connection between them. I know enough about winsock for this to be trivial if the connection is started from server B, but I need server A to start the connection.
I want to avoid using additional libraries if possible as it would appear to me that I only need to figure out what ip and port server A needs to use when starting the connection.
What additional information do I require, How do I acquire it, and How do I act upon the information.
note: I have investigated other similar questions, but none of them addressed this situation. I am not sure if this should have been asked on server fault or another site, but if so please say which one before flagging as "off topic" instead of closing the question wordlessly.
You need to setup port forwarding on the NAT device to the machine on the private network. Exact steps are device/manufacturer-specific, but here's the general idea:
Pick a port number, configure the NAT device so that connections to its public IP and that port are forwarded to the IP of your private server and the port where your application is listening.

Running multiple remote access instances of IPython with different profiles on the same port but accessed with different urls

I am currently running a single instance of a notebook set up for secure remote access on port 443 (https://example.com/ipython/). I would like to allow others to have access, but not to my main notebook. Is it possible to spawn multiple instances listening on the same port but with different url prefixes (such as /ipython-school/, /ipython-shared/, etc)? (as outlined here)
No it is a general technical limitation. You cannot have multiple app listening on the same port. You will have to rely on something that act as a proxy an forward request to multiple instance that listen on localhost on different port.