Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connect to local server with public ip #40

Open
ChristosPalisidis opened this issue Sep 12, 2019 · 11 comments
Open

connect to local server with public ip #40

ChristosPalisidis opened this issue Sep 12, 2019 · 11 comments

Comments

@ChristosPalisidis
Copy link

Hello,
I create a webserver, with wifi connection that the user can select. I want to have access to that web server without the need to being connected on the same network, with a public ip. This can be done with port forwarding.
Is this possible with UPnP and this library?
Thank you in advance!

@ofekp
Copy link
Owner

ofekp commented Sep 13, 2019

Hello @ChristosPalisidis,
This is exactly what this package is for.
Let me know if you have any issues.

@ChristosPalisidis
Copy link
Author

Hi @ofekp !! I appreciate your response!
So, i follow the "SimpleServer" example, providing my local IP and the port of my server to .addPortMappingConfig(). Am i supposed to be able to connect to the server from external networks, with the servers' public IP (which i possess with the help of ipify.org)?
So far, i didnt manage to achieve it. It seems that i am missing something.

@ofekp
Copy link
Owner

ofekp commented Sep 13, 2019

please connect to your device and provide a text file with the debug output, it will help me a great deal.

More things to try:

  1. Connect to your router and make sure UPnP service is enabled.
  2. You can browse the dynamic rules in your router so you may want to check that the rule you set up with addPortMappingConfig is there.
  3. If you think your service is up, please try this website to see that the port is indeed open:
    https://www.yougetsignal.com/tools/open-ports/
  4. sometimes routers will not allow for a loop to happen (they prevent calls from inside the network from reaching the router), I would try using a phone connected to a Cellular network just to make sure.

Let me know how it unfolded.

@ChristosPalisidis
Copy link
Author

UPDATE:
I connect my device to my phones network through tethering hotspot.I create the server and get his public IP from ipify.org. I run the procedure of port forwarding. My code continues without getting the "failed" print at the serial monitor .I then go to the aforementioned site, i provide the public IP that i got and my port (80) and get that it is not open on the IP provided.
I guess i have to check if UPnP service is enabled somehow?

@ChristosPalisidis
Copy link
Author

Also,
scanning all the common ports, i get that only the 443 SSL port is open on this public IP.
Is this a solution, to create a server on that port instead of port 80?
Thank you!

@ofekp
Copy link
Owner

ofekp commented Sep 16, 2019

I recommend that you use a different port than 80 and 443 and leave them be.
Use something like 5430 or 8980, anything four or five digits but less than 65535.
The port can be changed in the beginning of the .ino file.

To check your router config (for UPnP config or checking that the rule was set) you'll need its address, depending on the brand this can vary widely so please search online for the address or in your router's specifications.
Common IPs are:
192.168.1.1
192.168.2.1
10.0.0.1

It will help a great deal if you attach a text file with the output from your serial monitor.

@ChristosPalisidis
Copy link
Author

Unfortunately,using other ports, it happens that i can not have access to the server using the local ip either. It works only with port 80.
Another dificulty is that where i currently work my project,i can not have access to the routers address. Can i create the server on my phone's network and run and check the code? In this way, i will try to connect to the server from my pc, which is connected to the local network, so as to see if the public IP works.
Lastly, i can attach the text file of my serial, although it does not give any information and prints from that part of UPnP procedure concerning my whole code.

@ChristosPalisidis
Copy link
Author

I managed to check through https://badupnp.benjojo.co.uk/ that UPnP is not enabled in my router. The worse is that i do not have access to it and therefore cannot enable it. Can the procedure be done from my phones network as i said above?

@ofekp
Copy link
Owner

ofekp commented Sep 17, 2019

Nice way to check UPnP service! I learned something today!

Unfortunately, if your router is not configured to accept UPnP listings then you won't be able to gain much from this library (or any other UPnP library for that matter).

Not entirely sure about the phone set up, but if you planed to connect to a tethering hot-spot, then in this case your router is actually the mobile carrier. Yeah... good luck with telling them what to do!
You can do some fancy VPN setup to get this to work but this is rather complicated, if you're up for the task then get on to reading:
Some Stack Exchange Answer
Google search "port forwarding on mobile network"
Do let me know if you managed to set this up.

Otherwise, I would suggest starting from a setup where you have a control over the router.

@ChristosPalisidis
Copy link
Author

Thank you for the help @ofekp!
I will check it when i can to an accesible router.
Greetings!

@ofekp
Copy link
Owner

ofekp commented Sep 18, 2019

NP, let me know when you got the setup ready.
Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants