How to make TCP socket connection work over WAN with different ISP? - networking

I recently made a very basic TCP server application in C++ and Python using the very basic socket API. The client server connection happens flawlessly within the localhost as well as inside my LAN (within the same Wi-fi). But If I connect my client to an internet service (WAN) and try to connect to my server application behind my wifi (using the Wi-fi's public IP (provided by its ISP) and the port on which my server will be listening to) , I'm unable to get a connection. The server sits idle waiting for a connection ! I have enabled port forwarding on my Wi-fi, but still the results are all vain...
**EDIT: **
I managed to connect them over WAN, but now the ISP have to be the same... This is what I did: I made the server run on my Android device, bound it to the IP of my device that uses mobile data... The client sits behind a WiFi and connects to the Server using the previously mentioned IP and everything works fine ! But however if the client becomes an android app in another device with mobile data provided by different ISP everything fails !!! * So long as client runs behind a WiFi, but server connected to WAN (same ISP) the system works. *

Related

How to port forward external IP to websocket server hosted locally?

I have created a local websocket server using the ktor framework, which is available locally in the below IP.
[main] INFO Application - Responding at http://192.168.1.10:8080
And I'm able to access it locally from postman by hitting
ws://192.168.1.10:8080/chat
I would like to connect to this socket from the internet, But when I setup port forwarding (using NAT virtual server configuration), this doesn't seem to work. I get timed out error.
I tried this because, it is working fine for the http server (express app) I created in another port. From the below NAT virtual server configuration, I was able to do port forwarding and access the webservice from the internet.
I'm quite new to socket programming and networking. Kindly advice.
You can't have a single External Port mapped to two different Server ports. Each Server needs a distinct External Port mapped to it. Right now, you have External Port 80 mapped to both 192.168.1.10:3000 and 192.168.1.10:8080.
Once you fix that issue to use a separate External Port for each Server, then http://<externalIP>:<externalPort1> and ws://<externalIP>:<externalPort2> should work properly to reach the HTTP and WebSocket servers, respectively, from the outside world.

Unable to load localhost on web browser in Raspberry pi

I created a web server on my Raspberry pi using Apache2 and Wordpress. At the beggining I used a local network (IP is 192.168.1.103) and then used a Huawei dongle to connect to the internet. When the dongle is connected, web browser unable to load localhost. When dongle is used it shows that:
"The website at https://192.168.1.103/ seems to be unavailable"
How do I correct this error?
The IP address you're using to connect to the site is a local network address.
When the device is using a mobile data dongle it's no longer connected to your local network so the local IP no longer works.
You could find out your IP address when the dongle is connected however that's impractical. There's a good chance each time you reconnect the IP address will change. Your server needs to have a static IP address.
You cannot directly access a device on a Local network/LAN from the outside/WAN. Notice you are trying to connect to your localhost so you need to be directly connected to the device in question or through a medium which intenrally connects the devices together, such as a router/wifi hub.
When we break your steps down; you are trying to connect to a localhost/device on your LAN but you are connecting via dongle which is actually connecting via outside/WAN connection. This means your GET request for the localhost URL is going to the ISP/dongle providers server first then trying to get back into your LAN - this is not possible, hence the error.
Fix: Connect to device directly or via a medium such as a router (through ethernet or wi-fi).
Additionally: if you wish to type in a url instead of an IP then this will need to be resolved. This is done by manually typing in an entry in your hosts file (in the Raspberry Pi) and inputting the resoloution info i.e www.yourwebsitename.co.uk and local IP i.e. 127.0.0.1.
Your webserver (i.e. Apache) may need to be restarted for changes to take effect. If site is not loading correctly then it could be that your web browser is displaying a cached image in which case simply clear cache in your web broswer and reopen.

HoloLens emulator connect to server on LAN

I have a websocket server running on a pc connected to the pc through a switch.
When I make a websocket client in the HoloLens with the IP of the server it doesn't connect. How come? I cannot ping the HoloLens emulator from the pc with the server but I can ping the pc running the emulator.
By default all interactions with the emulator are done through a 169.254.xxx.xxx address. This address is not externally routable. If you go to the networking menu option in the web portal for the emulator you should see two network adapters, one is the 169.254.xxx.xxx address and another is an address assigned via dhcp. My guess is that you don't have a second adapter and need to fix that in your Hyper V configuration for the emulator. If you do have that second adapter pinging that address will not work, because HoloLens does not run and ICMP server to respond to pings. A better test is to open Internet Explorer in the emulator and attempt to go to a valid web server address on your network. Here is what my settings look like as an example:

Connecting to clients using proxy server

I need to build some software infrastructure to manage computers which are connected to the internet using a 3G modem (about 30-40 clients).
The scenario that I came up with for project needs:
Client established internet connection (this is made on OS startup - no user action needed)
Client make connection to some server in internet (I named it "PROXY" - maybe there is a better name)
From now client is connected to PROXY server and it is listening for connections on some port (static or dynamic port?)
The same is true for all other machines.
What I need:
When I connect to PROXY server I want to see list of all connected clients to it (optionaly time of connection, client IP etc)
I can make connection to any clients but not P2P I want to connect using PROXY server (some kind of tunneling?)
Access to client should be impossible without PROXY server.
Example:
Client connect to internet using 3G modem - received IP: 149.10.20.30
Client connect to PROXY (79.10.11.12)
I connect to PROXY (terminal / VNC / putty / whatever). I can list connected clients (ex. using some command: $ show_connected_clients). And I see list: IP / MAC or other informations.
From my computer (or PROXY server if this is simpler) I can make connection to client (terminal / VNC / RDP whatever) using for this PROXY server.
$ connect_to 149.10.20.30 using 79.10.11.12
Is such a thing is to realize with the help of the built-in OS services? Or maybe I need to use some commercial software or write my own application?
Writing this from scratch is possible but I do not want to reinvent the wheel.
Some advice? Thanks in advance for any help.
PS. Clients OS (probably all) is Linux. PROXY server OS - I can make decision by my own.
I've decide to use VPN. Perfect in its simplicity. If someone is interested.
Client connects to VPN. Gets IP from VPN network
VPN server on PROXY server
My machine connects to VPN
On PROXY server I can list connected clientes to VPN
Using (ex RDP) I can connect to any client by VPN network
I think I can configure client to deny connection from other network then VPN. If so, I have everything I need.
Simple :)

Communicate to a web application via application that is running on a PC that is connected to internet via Wifi

This is my application setup.
I have written an application (in Qt ) which will run on a linux computer (Ubuntu). The application accepts requests from web app and sends them to a serial device that is connected to the computer. Also application will send back the response to web app as well. This linux computer is connected to internet via wifi router.
Now my question is, Is there a way (other than port forwarding in wifi router) that I can achieve this functionality. Using port forwarding I can ask the router to forward the requests coming for a particular port to my computer at a particular port and my application would be listening for that. But for that I would have to configure the router and I don't want to do that. Is there a way I can do that automatically?
Thanks,
DPatel
Your issue is traversing non-routable NAT addresses.
UPNP is an option: http://en.wikipedia.org/wiki/Universal_Plug_and_Play
It will automatically configure port forwarding.
There is a library out there called STUNT for this as well:
http://nutss.gforge.cis.cornell.edu/stunt.php

Resources