[Workaround] Seadroid works great over Internet. Not so much over LAN

I’ve set up a new Seafile server on my home LAN and it works great except for one problem. I’m not sure if this is a server problem, a network problem, or a Seadroid problem. Any thoughts will be appreciated.

When my phone is connected to the Internet via my carrier’s LTE network, Seadroid works flawlessly (so far). When I connect my phone via WiFi to the same LAN as the server, things get flakey. Sometimes it works and sometimes it doesn’t. Mostly it doesn’t work.

Symptoms:

  • Login rarely works. The usual result is for the app to spin for a while and then display “Network Error”
  • Sync/Folder/File operations usually fail (but not always). The usual result is for the app to spin for a while and then display “Error when loading file/folder/libraries” “Tap to refresh.”
  • Sometimes (maybe half the time) the error message is accompanied by an Android toast message that says “Network Error.”

My laptop, connected to the same LAN via the same WiFi access point, has no difficulty connecting to and syncing with the Seafile server either via the web interface or via the Seafile client (that I am aware of).

Anyone have any thoughts on what might be going on?

System Specifics:

  • Seafile server is 7.0.4 running on Mint 19.1 (aka Ubuntu 18.04). Apache2 is proxying all communication. HTTP requests are redirected to HTTPS.
  • Seadroid is 2.2.18 running on Android version 9 (Pie)
  • Seafile Client is 7.0.2

WORKAROUND

I’ve figured out two workarounds that resolve this problem for me. I also now know why my laptop worked and my phone did not.

Unless your router supports NAT loopback (mine does not), you cannot reliably connect to a NAT’d resource’s public IP address from within the NAT’d LAN. I knew this many years ago. Guess I’m getting old. :confused: In my defense though, my laptop worked! See why below.

Workaround #1
Use a VPN. The reason my laptop worked and my phone did not is that the laptop is connected to a VPN. This effectively placed my laptop outside my LAN, and connections to my Seafile server’s public address worked just as if they had come from any other client on the internet.

Workaround #2
Use a local proxy server. This method insures that connections from within the LAN never hit the NAT’d public IP address.

  1. Install and configure a web proxy server (I’m using Squid, but a non-caching server will work as well) on the machine running running the Seafile server.
  2. Add the Seafile server’s public hostname to the proxy server’s /etc/hosts file as an alias for localhost. On my server the hosts line reads: “127.0.0.1 localhost www.myseafileserver.com” The important thing is the proxy server resolves the public hostname of the Seafile server to the Seafile server’s LAN address, not to its public address.
  3. Configure the phone or computer to use the proxy server when connected to the Seafile server’s LAN (and not to use the proxy server from outside that LAN).

Note: The proxy server does not need to run on the same computer as the Seafile server. But it must be able to resolve the Seafile server’s public hostname to the LAN address.

When I was still using Seafile hosted in my LAN I also faced that issue. I used dnsmasq running as DHCP/DNS server (nowadays as part of PiHole) and this can also handle such an IP mapping, so I translated my public FQDN into a local LAN IP with dnsmasq.

Glad, you found a solution.

Running my own DHCP/DNS server would work too, although anyone contemplating that solution should be aware that it requires disabling the existing DHCP server on the LAN.

An additional benefit of the proxy server is that it can be configured to filter out advertising.

You are right, there mut not be 2 DHCP servers in the same network.
BTW, PiHole is exactly that, and ad and tracker disabling tool on DNS level.