The built-in webserver

Post your questions and help other users.

Moderator: Martin

Post Reply
bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

The built-in webserver

Post by bogdyro » 17 Oct 2018 21:33

Hello everyone. Question for wizard Martin. I'm trying to use the trigger HTTP request to send an apk file (with variable sizes, maybe as large as 20-30mb) between my phone and tablet running AM. I've got a limited internet connection so the ideea is to send the latest version of the apk between phones and not download it multiple times from the internet. Right now I'm automating Mixplorer to start a ftp server and download files through automagic which is hit and miss (don't know why but the server works only when it wants to ). I'm trying to use it when away from home wifi also by creating a hotpsot on my phone and connecting the tablet to it. The FTP server running on the phone is setup on the WAN IP and not the local IP 192.168.1.x so getting files from the tablet side doesn't work.
So, to the point, is the AM http webserver capable of handling large files like these ?(i've read the warning in the documentation :) ) I am getting a 0 bytes downloaded file. Is there any chance of this working, ever ?
Thank you

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: The built-in webserver

Post by Desmanto » 18 Oct 2018 06:03

I still don't get your exact network topology and server. Automagic http webserver can be used as typical webserver or local intranet. You can upload/download files to/from the webserver. As far as I test, It can handle big files but the speed is not well optimized for it. I would just use it to trigger the command and use MiXplorer to send the files instead. You can use MiXplorer ACTION_COPY. You can also start/stop MiXplorer FTP server using similar broadcast : viewtopic.php?f=4&t=7261

For Apk distribution, it is better to have one device as the central. Turn on the FTP server for this device and also the flow with Trigger HTTP request. When new app installed, and want to be sync accross others, use the http request to other devices and trigger them to retrieve the apk from the FTP server, using FTP download or MiXplorer ACTION_COPY. If it errors (timeout), then it will send another request to the device which act as FTP server, a command to restart the FTP server. Basically every device will have the Flow with trigger HTTP request and communicating each other using action HTTP request. It is very to similar to autoremote, except this work locally without internet

But since you have NAT, the server is at WAN, it seems your server can't trigger the flow at the client. It will be one side check then, at periodic timer (let's say everyday), it will check the central webserver to see any update of the apk. If there is, send command to copy the file and restart the FTP if error. Same concept but just one way communication. Or maybe if you can use port forwarding, you can forward the command to the certain port and still have the 2 way communication.

@Martin : Probably these can be added too as examples in the Send broadcast.
MiXplorer FTP or HTTP or TCP server : https://forum.xda-developers.com/showpo ... tcount=423
The server detail for automagic is here : viewtopic.php?f=4&t=7261

MiXplorer Copy Files/Folder : https://forum.xda-developers.com/showpo ... tcount=422
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: The built-in webserver

Post by bogdyro » 18 Oct 2018 18:12

Hi Desmanto and thx for the reply. In the spirit of not using any other third party apps, I would like to use only AM. Problem is I can't get it to dwonload a simple file. Basic setup: phone and tablet connected to home network. phone has trigger HTTP request with address:port and path /automagic/file.apk; tablet has action download URL with url address:port/automagic/file.apk.
On the phone the trigger gets 'tripped' but no file gets downloaded to the tablet (only a 0 bytes file). What could be wrong ? I imagine it's something wrong with the relative path to the file. Would you give me an example of what you've tried that worked? Thx

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: The built-in webserver

Post by Desmanto » 19 Oct 2018 01:15

At the phone which have the apk, you should add action Write HTTP Response File, choose your apk. Basically you can point the apk to somewhere else, it doesn't have to be the same path. But it will be easier if you just use the same path as the HTTP one, so you can map directly to the path. Or you can use slightly different folder, example /sdcard/apk. And replace the /automagic/file.apk to /sdcard/apk/file.apk.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

bogdyro
Posts: 241
Joined: 04 Apr 2015 15:14

Re: The built-in webserver

Post by bogdyro » 19 Oct 2018 05:54

Yes, with this action in finally works. It's bit more complex than it should be I guess but it's working and I've eliminated mixplorer from the equation. Thanks !

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: The built-in webserver

Post by Desmanto » 20 Oct 2018 11:14

Automagic web server seems meant to be trigger flow to execute action. To response incoming request, we always have to use another action to sent the response. This allow you to process something first (example the submitted data), then return the post-processed data.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply