Solved How to route all workstations to communicate to outside world through the local server (1 Viewer)

nector

Member
Local time
Today, 11:42
Joined
Jan 21, 2020
Messages
368
Hello people!

I have created a server that run Apache tomcat & Java JDK to communicate essential information or sales invoice data to another organization totally different from ours. This system works very well if run on the local server where Apache tomcat & JDK is installed.

Now we have forty workstations scattered in some branches, instead of installing Apache Tomcat & Java JDK on each machine or making them individual servers, I want all of them (Workstation) to go through only one local server that is running this distributed website to communicate the information or sending sales invoice data to an outside company just like it is done on the local server.

The nominated local server uses the VBA code below to communicate direct to an outside server, kindly note that the endpoints is incorrect for security reasons. So, since all the forty machines have the same FE installed on them, then how can I change the VBA code below on each workstation so that each workstation goes through the local server and communicate the sales invoice data to an outside computer in another company just like the local server does using the stated end point below:

Code:
Dim Request As Object
Dim stUrl As String
Dim Response As String
Dim requestBody As String
Dim Details As Variant
Dim strData As String
strData =""greetings", "Hellow World"" 'note body in Json
stUrl = "http://localhost:8080/jrasandboxtsdx/trnsSales/saveSales"
Set Request = CreateObject("MSXML2.XMLHTTP")
requestBody = strData
    With Request
        .Open "POST", stUrl, False
        .setRequestHeader "Content-type", "application/json"
        .send requestBody
        Response = .responsetext
    End With
 

Edgar_

Active member
Local time
Today, 03:42
Joined
Jul 8, 2023
Messages
425
Not sure I understand where you want your data to go.

Typically, if you want to work outside localhost, you just replace http://localhost:8080 with the address of the web server. The address can be a domain name or an IP address, and depending on how it is setup it may require to specify port number and/or https. The rest of the URL should stay the same.

If it has to go through your local server first and then through the web server, you could send the request to the local server first and then to the web server. So you'd change the address in your strUrl variable and repeat the code that you're showing it's below that variable.
 

nector

Member
Local time
Today, 11:42
Joined
Jan 21, 2020
Messages
368
Many thank Edgar sir, with your assistance I managed to use your idea and came up with the solution below:

This is what worked for me on windows 10/11


Add ALLOWED_HOSTS = ['*'] in nector settings.py file

run nector server with Java manage.py 0.0.0.0:YOUR_PORT. I used 8080 as my port.

Make firewall to allow access on that port:

Navigate to control panel -> system and Security -> Windows Defender Firewall

Open Advanced Settings, select Inbound Rules then right click on it and then select New Rule

Select Port, hit next, input the port you used (in my case 9595), hit next, select allow the connections, hit next again then give it a name and hit next for the last time.

4. Now find the ip address of your PC.

Open Command Prompt as administrator and run ipconfig command.

You may find more than one ip addresses. As I'm connected through wifi I took the one under Wireless LAN adapter WiFi. In my case it was 192.168.0.112

Note that this ip may change when you reconnect to the network. So you need to check it again then.

5.Now from another device (pc, mobile, tablet etc.) connected to the same network go to ip_address:YOUR_PORT (in my case 192.168.0.112:8080)



The lasting solution is to make the IP address static on the server so that I do not need to worry about the changes of IP address otherwise it will mean checking the IP address running on the server on every reconnection.
 

Edgar_

Active member
Local time
Today, 03:42
Joined
Jul 8, 2023
Messages
425
Glad to see my suggestion helped you solve your problem.

I thought the forty workstations were external to your server, but if everything is in the same network and only the main server will communicate with the external server, great. It would indeed not be necessary to have a server installed on each workstation for that kind of orchestration.
 

Users who are viewing this thread

Top Bottom