Write XML file from Android to PC over WiFi connection

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Mon Feb 27, 2017 11:29 am

AxWald wrote:Hi,just a thought: Why don't you just set up a FTP Server on your Win machine? FileZilla Server for instance?This should make things ways less complicated ...Have fun!
Hi AxWald ... Thanks for the idea.

First I want to say, that I'm new on Programmer and I really don't Understand about Web server and FTP
I just start reading on internet when Someone tell that FTP or Web server can solve my problem.

Actually I have install FTP Server
You can read on my first page thread.

Than I try to Create an Apps to create and send XML
I deploy it for PC and Android.
When I try In PC it works good
but When I try on Android it does not work.

SparkOut tells me that there is not libURL on Android.
Than I try another option to solve my problem.

but if you have idea how to solve my problem.
I would love to try your way....

Best Regards


Gilar Kadarsah
Gilar | from INDONESIA

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Write XML file from Android to PC over WiFi connection

Post by AxWald » Mon Feb 27, 2017 6:17 pm

Ooops,

yup, I see, you have set up half a data center already ...

My idea was much more simple:
  1. Set up FileZilla Server, and create a User in it. Should be done in about 5 min.
  2. Create a port redirection in your router, type "FTP Server".
  3. Use a script like below in your app, and be done.
(Not tested, just typed down. Read twice & debug before compiling!)

Code: Select all

function transmitFile whatFile
   set the defaultfolder to specialfolderPath("cache")  --  assume the file is here
   
   if there is a file whatFile then                  --  does the file exist?
      put whatFile into myLocalFile
   else
      return "File " & whatFile & " not Found!"
   end if
   
   -- now set up the FTP stuff:
   put "WhoAmI" into myUserName
   put "tHis PasSword coUld be BeTter" into myPassWord
   put "myDomain.biz/uploads/" into myFTPPath
   
   put "ftp://" & myUserName & ":" & URLEncode(myPassWord) \
         & "@" & myFTPPath  & myLocalFile into myFTPURL
   
   try
      put URL ("file:" & myLocalFile) into URL MyFTPURL
      --  this is for text files. "binfile:" can be helpful otherwise :)
   catch Err
      return Err                                  --  something went wrong.
   end try
   return empty                               --  that's what we want to see :)
end transmitFile
This works flawlessly for me *). Even on Android for what RunRev has not much love. The lacking libURL doesn't mean you cannot do anything net-related, there's some built in functions available nevertheless.

The crucial point is to make your machine (resp. the FTP server running on it) reachable to the outer world (where your Android lives). This is done in your router. Without it you'll have no success ever. Test it with a browser, put "ftp://222.333.222.333" into the URL field (with your real external IP instead) - you must get a log on window.

Have fun!

*) As mentioned, the script itself isn't tested. But I do these things on Android (writing logs & transmitting data to an FTP server). If it doesn't work, tell me; I'll find the working version ;-)

PS: I ignored this thread for a long time because of the "XML" in the title - for fear of bleeding eyes ;-)
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Write XML file from Android to PC over WiFi connection

Post by capellan » Mon Feb 27, 2017 11:28 pm

Hi all,

Probably Gilar could post a few screenshots from his Android device (Phone or Tablet)
showing the error messages (or successfully opened webpages) from his Local XAMPP server.

How is possible that his Router allows his Android web browser to access his Local XAMPP
server and (at the same time) blocks his Android web browser to access LiveCode
stack server "mchttpd"? :shock:

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Tue Feb 28, 2017 2:17 am

AxWald wrote:Ooops,

yup, I see, you have set up half a data center already ...

My idea was much more simple:
  1. Set up FileZilla Server, and create a User in it. Should be done in about 5 min.
  2. Create a port redirection in your router, type "FTP Server".
  3. Use a script like below in your app, and be done.
The crucial point is to make your machine (resp. the FTP server running on it) reachable to the outer world (where your Android lives). This is done in your router. Without it you'll have no success ever. Test it with a browser, put "ftp://222.333.222.333" into the URL field (with your real external IP instead) - you must get a log on window.
Hi AxWald ... thanks for your idea.
Let me try it.
capellan wrote: Hi all,

Probably Gilar could post a few screenshots from his Android device (Phone or Tablet)
showing the error messages (or successfully opened webpages) from his Local XAMPP server.

How is possible that his Router allows his Android web browser to access his Local XAMPP
server and (at the same time) blocks his Android web browser to access LiveCode
stack server "mchttpd"? :shock:
Hi capellan ... thanks for keep helping me to solve my problem.

Sorry, I Actually had uninstalled XAMPP.
Now I have Apche Installed and LiveCode Server.

After reading AxWald instaruction then I try to Install FTP Server again (stand alone)
Here what I got when execute "File Zilla Server.exe"

Code: Select all

FileZilla Server 0.9.60 beta
Copyright 2001-2016 by Tim Kosse (tim.kosse@filezilla-project.org)
https://filezilla-project.org/
Connecting to server localhost:14147...
Connected, waiting for authentication
Logged on
You appear to be behind a NAT router. Please configure the passive mode settings and forward a range of ports in your router.
Warning: FTP over TLS is not enabled, users cannot securely log in.
Gilar | from INDONESIA

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Tue Feb 28, 2017 3:54 am

Now... I Uninstall Apache and FTP Server
and I install XAMPP again ....

here what I got.
Image


Sorry about router blocking
I don't know about this before ftp://XXX.XXX.XXX.XXX
I just know know type XXX.XXX.XXX.XXX (Server IP) then connect to Apache Page. (i assume this is unblock)

Then what should I do to unblock the router?
Is this about this? https://avjacobsen.wordpress.com/2012/1 ... sive-mode/

The other problem is ... How I can write XML file on Android? ( i have success to create XML in Windows)
Actually... before sending XML file I have to create the XML file. so schema will look like this

Android create XML file - then the XML file would send by FTP over Wi Fi Connection to PC.


Best Regards



Gilar Kadarsah
Gilar | from INDONESIA

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Tue Feb 28, 2017 9:58 am

Just now ... I check with another PC on the same Network same system Windows 7. (WiFi Connection)
I type ftp://XXX.XXX.XXX.XXX on browser then I can get the same result on the localhost.
I can see the file on server

Then I check again with my Android and type "ftp://XXX.XXX.XXX.XXX "
the result is search engine result

Could someone explain me why it happen?
Gilar | from INDONESIA

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Write XML file from Android to PC over WiFi connection

Post by AxWald » Tue Feb 28, 2017 6:03 pm

Hi,
gilar wrote:Could someone explain me why it happen?
You're sure you're actually using WiFi with the Android? And have approbate settings in the router? For instance, I can set it up so that WiFi (or Guest-WiFi) cannot connect local machines ...

Since I read about some confusion regarding in house servers behind NAT routers, here a short setup that works for FileZilla server, passive mode:

What we need are 2 port ranges: the one to connect the server (1 port), and a range for further machine chatter. We accomplish this using the range of 54399 - 54900: 54399 as incoming port, 54400 - 54900 as the range where client & server can have their fun.
  1. Router:
    We configure a port forwarding of port 54399 - 54900 from the net to the same ports of the server machine. That's all.
  2. Firewall, on the server machine:
    1. Outbound: We grant both the "FileZilla Server.exe" as well as the "FileZilla Server" service full outbound privileges.
    2. Inbound: We allow incoming traffic on ports 54399-54900.
  3. FileZilla Server:
    1. General settings: We switch the listening port to 54399. Just to fool nosy "security software" that wants to protect us from incoming ftp traffic. And for more easy typable rules ;-)
    2. Passive mode settings: We use a "custom port range", you guessed it: 54400 - 54900.
      Caution: The server must know its external IP, either as number, URL or via dynDNS!
Now fire up your ftp client, and connect to your machine at port 54399 - Voilá!

This should be possible to translate for Apache & Co., too. It is written as an example (that actually runs here). The port numbers are exchangeable, I'd recommend to use some in the range above 50000, to avoid port collisions. A usable port range of 500 should be given, else there can be problems during heavy usage. More information about FileZilla net configuration (and explanations) can be found here.

Adding the part "Setting up FTP over TLS" is left as an exercise to the esteemed reader ;-)

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Tue Feb 28, 2017 6:45 pm

Hi ... AxWald.
Thanks for Detail Tutorial, I'll try it.
AxWald wrote:Hi,
You're sure you're actually using WiFi with the Android? And have approbate settings in the router? For instance, I can set it up so that WiFi (or Guest-WiFi) cannot connect local machines ...
I'm really not sure about this. and I don't know how to setup.
I'll reading more to know it. and I'll follow your instruction.


Than the importing things from all of this is how to create XML file on Android? because we i have to create XML file before I send it.

I hope there will be someone who has done with this and would explain here.

Best Regards.


Gilar Kadarsa.
Gilar | from INDONESIA

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Tue Feb 28, 2017 8:53 pm

Hi ... AxWald.

With Port Forwarding
Now I can get my FTP Server
Thank you very much

Then I will test your code and deploy to Android
Soon I will write the progress here

Best Regards



Gilar Kadarsah
Gilar | from INDONESIA

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Write XML file from Android to PC over WiFi connection

Post by AxWald » Tue Feb 28, 2017 9:50 pm

Hi,

just quickly: Be sure to be in the correct directory on Android when creating a file - you're caught in a virtual file system & only have few possibilities! SpecialfolderPath("cache") works in any case, and is persistent.

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

gilar
Posts: 96
Joined: Sat Sep 26, 2015 12:59 pm

Re: Write XML file from Android to PC over WiFi connection

Post by gilar » Tue Feb 28, 2017 10:04 pm

Here some trial connection
  1. A. Android connect to Internet by It self
    -. on Browser and type ftp://public-ip:portforwarding, result ===> I can login to FTP server
    -. on Browser and type ftp://server-ip, result ===> Object Not found, Error 404
  • B. Android connect to WiFi Modem/Router (with internet connection)
    -. on Browser and type ftp://public-ip:portforwarding, result ===> Got the Error: Not Found
    -. on Browser and type ftp://public-ip, result ===> Got the Error: Not Found
    -. on Browser and type ftp://server-ip:portforwarding, result ===> your search didnot match any document
    -. on Browser and type ftp://server-ip, result ===> search engine result
question
What should I do, if I want to connect to server by WiFi? (with or without internet connection)


Thanks


Best Regards
Gilar Kadarsah
Gilar | from INDONESIA

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: Write XML file from Android to PC over WiFi connection

Post by AxWald » Tue Feb 28, 2017 10:38 pm

Hi,

may be server misconfig. My Android (4.2.2, on WiFi, with Firefox):

ftp://mydynDomain.biz:54399 => login screen
ftp://93.127.24.112:54399 => login screen

Your user has a directory attached in "Users/ Shared Folders", and at least Read/ List permission?

Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply

Return to “Android Deployment”