Web server for public over internet

443 views
Skip to first unread message

Munawar Hussain

unread,
Jul 31, 2020, 1:56:48 AM7/31/20
to DroidScript
Creating and running web server work locally, how same server public can access over internet?

Steve Garman

unread,
Jul 31, 2020, 3:47:45 AM7/31/20
to DroidScript
The answer to this is normally to set up port forwarding.

This may or may not be allowed by your isp. You should check their terms and conditions.

The method of doing it varies greatly from router to router.

On my router I log in as "admin", open "Advanced settings" and choose "firewall"

Please be careful. You need to find out what you are doing before making any changes to your router's settings.
You can easily make the internet inaccessible from your whole home network.

If you do not have a manual for your router, seek advice from your ISP or download a manual before starting.

Always backup your router configuration locally (not cloud storage) before you make changes.

It is usually pretty safe to assume that these sort of changes cannot be applied to mobile (cell) data connections.

Once the port-forwarding is set up, users outside your local network will need to access your server using your router's external IP address, not the local address (likely 192.168.xxx.xxx) which you are probably currently using.

Please note that, unless you have a fixed IP address, your external address will probably change whenever your router is rebooted or if its connection is interrupted.

In most countries fixed IP addresses are not normally provided unless you request them specifically.

Munawar Hussain

unread,
Jul 31, 2020, 3:59:58 AM7/31/20
to DroidScript
I am using mobile sim internet at same phone which running web server, no need to worry about router configuration, after web server start it is work locally, now what steps to do to work for public ?

Steve Garman

unread,
Jul 31, 2020, 4:08:21 AM7/31/20
to DroidScript
You won't be able to do that.

In my previous post I said "It is usually pretty safe to assume that these sort of changes cannot be applied to mobile (cell) data connections."

Munawar Hussain

unread,
Jul 31, 2020, 5:17:48 AM7/31/20
to DroidScript
I saw Apache with some DNS setup peoples are live with cell phone internet, why not with DS ?

Steve Garman

unread,
Jul 31, 2020, 5:30:25 AM7/31/20
to DroidScript
I haven't seen that. Perhaps you could provide a link.

Munawar Hussain

unread,
Jul 31, 2020, 6:31:40 AM7/31/20
to DroidScript

Steve Garman

unread,
Jul 31, 2020, 7:17:53 AM7/31/20
to DroidScript
You can do that with a DroidScript webserver if you want to but I wouldn't recommend using any app that can't even get itself listed on Google Play be given that much access to your phone.

It works (if it works at all) by making an outgoing connection to pagekite's server

Everything up to the pagekit bit can be done with the "HTTP Server" sample that comes with DroidScript.

If you decide to try pagekit please be aware that you are doing so against my advice.

Munawar Hussain

unread,
Jul 31, 2020, 7:32:34 AM7/31/20
to DroidScript
It was just one reference, plenty of other examples available at play store under dynamic DNS, i am asking how I can with DS to make available DS web server with DS help for Dynamic DNS.

Munawar Hussain

unread,
Jul 31, 2020, 7:38:34 AM7/31/20
to DroidScript
I mean if other peoples can make dynamic DNS apps, then how i can with DS for my app ?  I wish to give my app web server with DS and also dynamic DNS facility to make this web server public.

Steve Garman

unread,
Jul 31, 2020, 7:51:07 AM7/31/20
to DroidScript
Dynamic DNS is very useful if you have a device that will accept incoming connections but the IP address keeps changing.

It only works if the Dynamic DNS server is outside your local network.
If you are going to use one of those, choose one that has a JavaScript API so you can write some updater code in your DroidScript code.

However, you are unlikely to get this working with only a phone.

Anything you are describing will need interaction with some outside website.

Munawar Hussain

unread,
Jul 31, 2020, 9:35:29 AM7/31/20
to DroidScript
How DS will show IP which my mobile phone using on public network?

Steve Garman

unread,
Jul 31, 2020, 9:40:53 AM7/31/20
to DroidScript
var ip
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
txt = app.CreateText( "Checking" );
lay.AddChild( txt );
app.AddLayout( lay );

getIpAddress();
}

function getIpAddress()
{
app.HttpRequest( "GET",
"http://bot.whatismyipaddress.com",
"/",
"",
HandleReply,
"" );
}

function HandleReply( error, response )
{
if(error) txt.SetText("failed");
else txt.SetText(response);
}

Steve Garman

unread,
Jul 31, 2020, 9:55:13 AM7/31/20
to DroidScript
I suppose I should have set the value of ip really

function HandleReply( error, response )
{
if(error) txt.SetText("failed");
   else
{
txt.SetText(response);
ip = response;
}
}

Munawar Hussain

unread,
Jul 31, 2020, 11:05:35 AM7/31/20
to DroidScript
Hi,
What do you suggest Dynamic DNS is better or IP is fine to share web server contents over public network?
Or any better solution for this ?
Thank you.

Kallikratidas

unread,
Jul 31, 2020, 6:05:38 PM7/31/20
to DroidScript
Dynamic dns should be preferred always when you do not own a static IP address. If you have a static IP address, then you could use the IP address.
The dynamic dns just maps your dynamic IP to a domain.

Now, as regarding the port forwaring:
Be careful, because your ISP may not allow port forwaring for some reasons.

Your router or modem firewall may not allow external port forwarding. Only internal. Go to your router settings and disable firewall or use a firewall level that allows you to port forward.

Always add your device that is used as a web server to a DHCP static lease! Always! Otherwise the router after the DHCP lease time will not be able to port forward your device as it's IP will(may) have changed!

DroidScript can be used for creating a web server that can be port forwarded. I have tested this.

Just create you web server app and then set the port forward options to your router.

app.CreateWebServer(8080);
app.GetIPAddress();

This is all you want.

Just go to your router's NAT settings in the Port Forwarding option and add your web server.

Active: true
Type: WWW
Internal Port(s) : 8080-8080//use the same port
External port(s) : 80-80

Kallikratidas

unread,
Jul 31, 2020, 6:07:05 PM7/31/20
to DroidScript

Munawar Hussain

unread,
Aug 4, 2020, 6:46:55 AM8/4/20
to DroidScript
Tried DDNS but still no success to see it active  pakexpo.ddns.net , at mobile apache and ddns app running, with ip i found it working in browser , example  ip/8080  then it shows page, ip i got from settings, but with ddns still no sucess.

Kallikratidas

unread,
Aug 4, 2020, 9:16:30 PM8/4/20
to DroidScript
Forget the ddns for a moment. Does the port forwarding work? If you type your public IP address are you able to access your server?
If yes, then check your router Dynamic DNS settings. It may not be authorized but the no-ip service. Make sure that your router informs the no-ip about your public IP address. Otherwise, go to the no-ip.com and login and map your public IP address manually.

Munawar Hussain

unread,
Aug 5, 2020, 3:49:41 AM8/5/20
to DroidScript
I have checked with "IP Webcam" app, it is informed my mobile phone IP is in private range 10.*.*.* . It will not work in public network.

Munawar Hussain

unread,
Aug 6, 2020, 3:25:43 AM8/6/20
to DroidScript
Tried anonymous surf to access all links for test purpose, but no success. 

Munawar Hussain

unread,
Aug 6, 2020, 3:30:08 AM8/6/20
to DroidScript
http://172.17.201.90:8080/  "IP Webcam" app give me this url to access, at my network it is working, i can access page , but when i did anonymous surf, i can not.

Munawar Hussain

unread,
Aug 6, 2020, 3:45:30 AM8/6/20
to DroidScript
I use anonymous surf to check if links are working from other places, but not a single work able example i found, not with DS web server , not with "IP webcam" app, i aim is to use mobile phone internet for this purpose,  because many places do not have wifi or other internet service.

Steve Garman

unread,
Aug 6, 2020, 3:50:37 AM8/6/20
to DroidScript
Let me repeat what I told you right at the beginning of this thread

Mobile phones in most countries do not allow inward connections

If you are connecting to the internet via a router you can usually reconfigure the router to accept incoming traffic on a range of ports.

You cannot do that with a mobile phone.

Steve Garman

unread,
Aug 6, 2020, 3:56:31 AM8/6/20
to DroidScript
To be clear, you can use a server on a mobile phone if the phone is connected via a router and the router is configured to allow inward connections to that device.

There is no way to do the same thing if the phone is online through its own data connection instead.

Munawar Hussain

unread,
Aug 6, 2020, 9:50:14 AM8/6/20
to DroidScript
It seems strange, from same mobile phone and sim services peoples can go live with Facebook, with Whats App can talk live with video, but when i am asking to share contents over internet with peoples then i am getting answer "not possible" .

Steve Garman

unread,
Aug 6, 2020, 10:00:40 AM8/6/20
to DroidScript
You can share stuff over the internet provided you make an OUTgoing connection to a server.

That is how all social media works for everyone, whether they are connecting from a phone or any other way.

If you think you should be able to receive an INcoming connection to your mobile phone over the data connection ask your mobile phone provider

Munawar Hussain

unread,
Aug 6, 2020, 10:25:36 AM8/6/20
to DroidScript
Please suggest :
Things to do is provide access to users to mobile phone over internet, they can see pictures with mobile camera, videos, and get files which they required.
I was thinking with web server to put things on it, then peoples over internet can access.
But still no success.
Now any other solution ? 

Dave

unread,
Aug 6, 2020, 3:23:51 PM8/6/20
to DroidScript
Do you have an online Linux box available? 

If so, then you might be able to use an ssh tunnel if you can find an SSH app or binary for Android.

Munawar Hussain

unread,
Aug 7, 2020, 7:17:23 AM8/7/20
to DroidScript
Let me explain situation.
We are working on monitoring system.
This system base on smart phone and sensors which will fix at farm.
Sensors connected with wire to smart phone.
Humidity, temperature data we are saving on smart phone.
Farm owner needs to know situation of farm at home or office.
One solution is Team Viewer or Air Droid to connect farm mobile remotely to get data and pictures etc.
Other solution I thought to run web server at farms mobile phone, then owner of farm can have access from any where to know situation, but it is not working as we discussed.
I wish to make easy configurable system which very low literate peoples also can run.
Also I am very short in funds, can not afford servers, I thought this project will help me to generate income to make it more good, but still no success in income cash.

Dave

unread,
Aug 7, 2020, 7:28:40 AM8/7/20
to DroidScript
What I suggest is that you use our CloudStore service to store your data and the free tear of https://www.filestack.com/ to hosts your images.

You can post JSON data from your phone to the CloudStore on a regular basis containing temperature and humidity etc and upload images to the filestack database via their AJAX API at regular intervals or on a trigger via the CloudStore service.  You would store the URL to the current image in the CloudStore service too.


Munawar Hussain

unread,
Aug 7, 2020, 7:50:19 AM8/7/20
to DroidScript
Seems nice, does this solution cost?

Dave

unread,
Aug 7, 2020, 7:57:23 AM8/7/20
to DroidScript
Only the cost of a DS Premium membership :)

Dave

unread,
Aug 7, 2020, 7:57:54 AM8/7/20
to DroidScript
You will need to use the new Beta version of DS BTW

Munawar Hussain

unread,
Aug 7, 2020, 8:38:02 AM8/7/20
to DroidScript
Some times i bought premium, but not all the time, also using old DS version which support Android 4.4.2, what about Google to store data? because free many things, can afford more (users) peoples.

Kallikratidas

unread,
Aug 7, 2020, 11:57:41 AM8/7/20
to DroidScript
You could try for better performance and at no cost Google Firebase and Firestore, but I think it is better to support DroidScript by upgrading to premium...

Munawar Hussain

unread,
Aug 7, 2020, 12:03:51 PM8/7/20
to DroidScript
If store data to google drive, then at least user can see details , files, pictures etc from other place, i hope google do not mind to access same account from farm mobile phone and from other place, but this way is not like live as thought with web server.
Message has been deleted

Kallikratidas

unread,
Aug 7, 2020, 11:59:09 PM8/7/20
to DroidScript
Who said Google Drive???? We are discussing Google Firebase here and Google Firestore. Please just Google it and then send your answer again...

Munawar Hussain

unread,
Aug 8, 2020, 12:05:35 AM8/8/20
to DroidScript
Any sample code to upload folder with files to Google drive?

Kallikratidas

unread,
Aug 8, 2020, 1:09:01 AM8/8/20
to DroidScript
First of all, did you take a look at the Google Drive's API?

https://developers.google.com/drive/api/v3/quickstart/js

But I don't understand why you got stack with GooglDrive. Google Firestore allows you to upload folder and files realtime! Why did you reject the Google Firestore solution? Is there any specific reason?

Regards

Munawar Hussain

unread,
Aug 8, 2020, 2:17:48 AM8/8/20
to DroidScript
Hello, Hope things fine there.
I am not rejecting, i am new, may be mistakes.
I wish to make easy, and cost effective, Google Firestore is free ? if yes then may i see example to use it ?

Munawar Hussain

unread,
Aug 8, 2020, 2:37:59 AM8/8/20
to DroidScript
No success with this.

//Send an image to Google Drive.
function btnImg_OnTouch()
{
    var file = "/sdcard/MyDroid.jpg";
    img.Save( file );
    
    var packageName = "com.google.android.apps.docs";
    var className = "com.google.android.apps.docs.shareitem.UploadSharedItemActivity";
    var action = "android.intent.action.SEND";
    var category = "android.intent.category.DEFAULT"
    var uri = null;
    var type = "multipart/*";
    var extras = [
        {name:"android.intent.extra.STREAM", type:"file", value:file},
        {name:"android.intent.extra.SUBJECT", type:"string", value:"MyDroid.jpg"},
    ];
    
    extras = JSON.stringify( extras );
    app.SendIntent(packageName, className, action, category, uri, type, extras);
}

Munawar Hussain

unread,
Aug 10, 2020, 5:08:19 AM8/10/20
to DroidScript
I have tried to upload files to Google drive but no success with DS and no success with phone itself, what could be reason?
Message has been deleted

Alan Hendry

unread,
Aug 10, 2020, 5:48:12 AM8/10/20
to DroidScript
Hussain,
When you say "no success with phone itself," do you mean that the Google Drive on the app doesn't work?
That would hint at a problem outside DS.
Is img defined globally (var img before OnStart)?
Does it create  /sdcard/MyDroid.jpg ? 
Regards, ah

Hin Haale

unread,
Aug 10, 2020, 5:33:01 PM8/10/20
to DroidScript
Hey, sorry for butting in - delete when read :)
Couldn't find a report problem subdir, just wanted to inform that the gage-gadget in the droidscript app, works for all except for Temperature - you get to a 404 so
Re-upload/rewrite pointing to a path with the tempurature.. blabla as I'm sure you know more than me of.

I'm just the Whistle-blower, bringing your attention to inside secret, hidden bugs/etcetera. (⌒▽⌒)
This was so Majorly serious I just had to sing, sorry guys :D 
 
Cheers!  o/

fredag 31 juli 2020 kl. 09:47:45 UTC+2 skrev steve....@gmail.com:
The answer to this is normally to set up port forwarding.

This may or may not be allowed by your isp. You should check their terms and conditions.

The method of doing it varies greatly from router to router.

On my router I log in as "admin", open "Advanced settings" and choose "firewall"

Please be careful. You need to find out what you are doing before making any changes to your router's settings.
You can easily make the internet inaccessible from your whole home network.

If you do not have a manual for your router, seek advice from your ISP or download a manual before starting.

Always backup your router configuration locally (not cloud storage) before you make changes.

It is usually pretty safe to assume that these sort of changes cannot be applied to mobile (cell) data connections.

Once the port-forwarding is set up, users outside your local network will need to access your server using your router's external IP address, not the local address (likely 192.168.xxx.xxx) which you are probably currently using.

Please note that, unless you have a fixed IP address, your external address will probably change whenever your router is rebooted or if its connection is interrupted.

In most countries fixed IP addresses are not normally provided unless you request them specifically.

munawarhu...@gmail.com

unread,
Aug 27, 2020, 7:43:53 AM8/27/20
to DroidScript
I am stuck, DS or DS beta at both I am getting same problem, Google drive app updated, but when storing files to it, no success.
IMG_20200825_172420.jpg
Reply all
Reply to author
Forward
0 new messages