Error using rclone serve dlna on Termux

Hmm, must be something to do with the Termux/android environment but I don't know what :frowning:

I received this answer on the Termux subreddit, so it's definitely and Android permission problem:

Hi, I was able to confirm this on my phone today. It works if you run it as root. I am sure this is due to termux running as proot, thus the Android system is always an upper level in hierarchy. So in order to modify any network routes you have to call the command as root.

At this point, however, I don't understand how the Kodi Android app can create a functional DLNA server without root permissions.

Hmm, I wonder if we are attempting to send out of the wrong interface or something like that

If you run server dlna with -vv it will print which interfaces it is attempting to use.

The packet being blocked is a multicast packet this may be relevant: https://stackoverflow.com/questions/13221736/android-device-not-receiving-multicast-package

As far as I can see there isn't a go native way of acquiring the multicast lock (at least not in gomobile).

This is the termux issue for allowing it to add a multicast lock:

Thanks for pointing out the Termux issue (that, unfortunately, does not seems very active).

This is my rclone serve dlna -vv Drive-crypted: output:

2019/08/15 15:48:57 DEBUG : rclone: Version "v1.48.0" starting with parameters ["rclone" "serve" "dlna" "-vv" "Drive-crypted:"]
2019/08/15 15:48:57 DEBUG : Using config file from "/data/data/com.termux/files/home/.config/rclone/rclone.conf"
2019/08/15 15:48:59 DEBUG : Adding path "vfs/forget" to remote control registry
2019/08/15 15:48:59 DEBUG : Adding path "vfs/refresh" to remote control registry
2019/08/15 15:48:59 DEBUG : Adding path "vfs/poll-interval" to remote control registry
2019/08/15 15:48:59 NOTICE: Encrypted drive 'Drive-crypted:': Serving HTTP on [::]:7879
2019/08/15 15:48:59 INFO  : DLNA server on :7879: Started SSDP on lo
2019/08/15 15:48:59 INFO  : DLNA server on :7879: Started SSDP on wlan0
2019/08/15 15:48:59 INFO  : DLNA server on :7879: Started SSDP on rmnet_ipa0
2019/08/15 15:48:59 INFO  : DLNA server on :7879: Started SSDP on rmnet_data0
2019/08/15 15:48:59 INFO  : DLNA server on :7879: Started SSDP on dummy0
2019/08/15 15:48:59 error writing to UDP socket: write udp 0.0.0.0:1900->239.255.255.250:1900: sendto: operation not permitted

Thanks for that... It gives me an idea - we are trying to multicast on interfaces which can't multicast.

I attempted to fix that here

https://beta.rclone.org/branch/v1.48.0-191-ge8fe5a9e-fix-dlna-beta/testbuilds/ (uploaded in 15-30 mins)

There should be an android build in there, however you might need to build it from source under termux, in which case you'll need the fix-dlna branch

Probably I did something wrong (I am not a programmer, I try to do what I can :sweat_smile:), this is what I have done:

  1. I tried using the prebuilt binary from the rclone-v1.48.0-191-ge8fe5a9e-fix-dlna-beta-linux-arm64 zip, but the commands did not work. With the -vv option I got:
    2019/08/16 11:23:23 DEBUG : rclone: Version "v1.48.0-191-ge8fe5a9e-fix-dlna-beta" starting with parameters ["rclone-test/rclone" "-vv" "ls" "Drive-crypted:"] 2019/08/16 11:23:23 DEBUG : Using config file from "/data/data/com.termux/files/home/.config/rclone/rclone.conf" 2019/08/16 11:23:23 DEBUG : pacer: low level retry 1/10 (error Get https://www.googleapis.com/drive/v3/files?alt=json&fields=files%28id%2Cname%2Csize%2Cmd5Checksum%2Ctrashed%2CmodifiedTime%2CcreatedTime%2CmimeType%2Cparents%2CwebViewLink%29%2CnextPageToken&includeItemsFromAllDrives=true&pageSize=1000&prettyPrint=false&q=trashed%3Dfalse+and+%28%27root%27+in+parents%29+and+%28name%3D%27DDD%27%29+and+mimeType%3D%27application%2Fvnd.google-apps.folder%27&supportsAllDrives=true: dial tcp: lookup www.googleapis.com on [::1]:53: read udp [::1]:38128->[::1]:53: read: connection refused) 2019/08/16 11:23:23 DEBUG : pacer: Rate limited, increasing sleep to 1.424603083s

  2. I tried building it from source under Termux, in this way:

But at the end I get build google.golang.org/grpc/internal/syscall: cannot load google.golang.org/grpc/internal/syscall: no Go source files and it does not build the binary.

Grrr, looks like the Circle CI builder

  1. doesn't build binaries for branches for some reason
  2. doesn't build ARM64 builds!

You are trying a vanila linux/arm64 build which won't work with DNS issues.

ANd that looks like a bug in the grpc library with the android build target.

You can work around that like this

rm vendor/google.golang.org/grpc/internal/syscall/syscall_nonlinux.go
vi vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go # delete first line with +build in it
mv vendor/google.golang.org/grpc/internal/syscall/syscall_linux.go  vendor/google.golang.org/grpc/internal/syscall/syscall.go 
go build -mod vendor -v

That should hopefully build an rclone binary for you! (it did for me anyway).

When I tried it I got this, so no errors about SSDP anyway...

$ ./rclone serve dlna . -vv
2019/08/20 14:48:23 DEBUG : rclone: Version "v1.48.0-DEV" starting with parameters ["./rclone" "serve" "dlna" "." "-vv"]
2019/08/20 14:48:23 NOTICE: Config file "/data/data/com.termux/files/home/.config/rclone/rclone.conf" not found - using defaults
2019/08/20 14:48:23 INFO  : Local file system at /data/data/com.termux/files/home/rclone: poll-interval is not supported by this remote
2019/08/20 14:48:23 DEBUG : Adding path "vfs/forget" to remote control registry
2019/08/20 14:48:23 DEBUG : Adding path "vfs/refresh" to remote control registry
2019/08/20 14:48:23 DEBUG : Adding path "vfs/poll-interval" to remote control registry
2019/08/20 14:48:23 NOTICE: Local file system at /data/data/com.termux/files/home/rclone: Serving HTTP on [::]:7879
2019/08/20 14:48:23 INFO  : DLNA server on :7879: Started SSDP on wlan0
2019/08/20 14:48:25 INFO  : /static/ContentDirectory.xml: 10.2.1.50:37827 GET 200  %!s(<nil>)
2019/08/20 14:48:25 INFO  : /static/ConnectionManager.xml: 10.2.1.50:37827 GET 200  %!s(<nil>)
2019/08/20 14:48:25 INFO  : /static/X_MS_MediaReceiverRegistrar.xml: 10.2.1.50:37827 GET 200  %!s(<nil>)
2019/08/20 14:48:26 INFO  : /static/rclone-48x48.png: 10.2.0.239:50871 GET 200  %!s(<nil>)

Thanks, it worked for me too with your workaround... but unfortunately the base problem persists (only images are listed) :pensive:.

Hooray!

Boo :frowning:

I'll merge that fix anyway since I don't think it makes things worse and is more correct.

Can you see if you can copy a video to a local directory in termux then try rclone serve dlna localdir and see if that gives a different result?

Of course, unfortunately I get the same result (only images).

I think if we want to make progress we need to try to discover the difference between running under termux and running on your PC...

Maybe you could use wireshark to packet capture both and see if you can spot a difference?

Someone else on https://github.com/rclone/rclone/issues/3253 mentioned that they can only see photos and not stream stuff...

I don't know why that might be - it might be worth asking @sretlawd directly on that issue.

I will try, but I think it goes beyond my capabilities :cold_sweat:

Try asking @sretlawd on the github issue, or maybe make a new github issue. I'm not an expert on dlna so we need his help I think!

New GitHub issue made:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.