Kodi's SMB/SSH client transfer speed low when behind OpenVPN

Hi,

Setup:
I have two Raspberry PI 2 Model Bs each located in a different country. The first Rpi2 runs the latest Rasbian Jessie and acts as an OpenVPN server (and SSH, SMB server as well). It also has an external hard drive attached to it via USB. The pi is connected to a fiber optics network via ethernet and has download/upload speeds of 100 Mbits (=12.5 MBs).

The second Rpi2 runs the latest OSMC and alongside Kodi acts as a OpenVPN client as well. It is connected to a solid network via ethernet and has download/upload speeds of 25 Mbits (=3.125 MBs) and 1 Mbits (=0.125 MBs) respectively. Moreover, when the OpenVPN client Rpi2 (OSMC) connects to the OpenVPN server Rpi2 (Jessie), a simple http command line speedtest shows almost a 25 Mbits (=3.125 MBs) download speed, hence we can see that the client basically use all of the available bandwith, which is what I want and expect.

Use case:
I want to use my OSMC client pi to first connect to the OpenVPN server pi and then connect to the Samba share to access my hard drive’s content vai Kodi. I am able to do this by using the Kodi’s built in Samba client (via Add Network location). After establishing an OpenVPN tunnel, I can then connect to the server pi via Kodi’s SMB or SSH and access the needed files. However, the issue is that whenever I copy a file from the server to the client via the built-in Samba client (the same happens with SSH), the download speed is only around 4 Mbits (=0.5 MBs).

Naturally, I did some additional testing to try to figure out where the issue lies.

  1. When I connect to the OpenVPN server from my Mac (OpenVPN client) and do a file transfer over SMB via Finder’s built-in Samba client, then the transfer speed is great - it uses all bandwith of 25 Mbits (=3.125 MBs). The speed is the same when I do a file transfer over SSH as well. So there is nothing wrong with the pi’s SMB/SSH server when running over OpenVPN tunnel. But when I do the same via Kodi’s Samba client, then the download speed is only around 4 Mbits (=0.5 MBs) - the exact same issue as with my OSMC Rpi2 acting as an OpenVPN client.
  2. When I do a file transfer via Kodi’s samba client from a samba server located at local network, then the speed is close to 100 Mbits (=8.125 MBs). This is as expected.

Conclusion
I speculate that the issue lies at Kodi’s way of handling SMB and SSH client, because when behind an OpenVPN tunnel they slow down the transfer speed. This happens on Kodi runnning on both OSMC and Mac OS X.

Question:
Does anyone have any ideas on how to fix this?

Thank you!

SMB is not designed to be used over high latency networks - and connecting from one country to another definitely counts as high latency.

The built in sshfs client in Kodi performing very poorly over high latency connections is a known issue that the Kodi devs are aware of, but is not likely to get fixed any time soon. I suspect the built in SMB client would suffer similarly over a high latency (>100ms) connection too.

Your best bet would be to use kernel mode sshfs or smb (cifs) mounts by mounting your remote drives in /etc/fstab, and you might need to use some additional mount options to optimise the performance over high latency.

  1. The distance between countries is less than 1000km and both use solid ISP’s. Server’s latency to the ISP is 4ms, client’s 18ms. I just checked and latency over VPN is 63 ms. I would say that this is not much and significantly less than 100ms.
  2. I will repeat what I wrote in the original post. When using my Mac’s OpenVPN client, the SMB and SSH transfer via Finder use all bandwith 3.125 MB. This leads me to think that there is something wrong Kodi’s SMB and SSH clients when used over OpenVPN tunnel.

Any more ideas?

63ms is still “high latency” for a protocol designed to operate over Ethernet.

Maybe you didn’t read my post properly - because I just explained that Kodi’s built in sshfs and smb clients do not work well with high latency connections, and recommended you try using a kernel based mount in /etc/fstab.

When you use smb and ssh directly via the finder on a Mac you are not using Kodi’s inbuilt smb and sshfs clients, obviously. You are using operating system level clients.

So try using kernel mounts as suggested and see if you still get slow performance.

Alright, will do so and report back! Thanks

I just tried out the suggested method of mounting my OpenVPN server’s samba share as a kernel based mount. In order to “proof the concept” I did the following:

  1. Established a tunnel between my OSMC OpenVPN client and Jessie OpenVPN server.
  2. Successfully mounted the share by running the following command at OSMC:
    sudo mount -t cifs -o username=removed,password=removedi //10.99.99.120/samba/ /mnt
  3. At Kodi found the mounted share and tried both streaming and copying a file from the server. The results are great - streaming was stutter free and copy showed around 2 MBs transfer speed (still not close to the max client’s bandwidth of 3.125 MB/s, but 4x faster than the Kodi’s built-in client).

Overall I am happy with the results and would like to implement a permanent solution. Hence I would appreciate some guidance with the following:

  1. Are there additional options for the mount command, which would allow to increase the transfer speed closer to the max bandwith?
  2. Intuitively it seems that I would want to automatically mount the share right after a tunnel to my OpenVPN server is established as well as automatically unmount the share right before the tunnel is disconnected. This implies that I do not need the share to be mounted automatically on boot. Any ideas on how to implement this in a simple and elegant way? I have to add that I am exclusively using the OpenVPN Kodi addon (github) to connect to/disconnect from my OpenVPN server - perhaps it is possible to do some simple adjustments to the addon code to run that one mount line?

Thanks!

Yes!! You safe my day!
I was connect to my rural home with fiber optic connection using PPTP tunnel which is super fast.
200km from my apartment, latency was just 12ms comparable to older wide area ethernet network.
Everything work well except using SMB source inside Kodi(OSMC) was abysmally slow. maximum transfer rate of just 5-6Mbps.
I even buy a new router to offload the tunneling process out of my Raspberry Pi. no improvement.

Just mounted the share using OS component like your method and “Boom!”.
I’m now able to max out all my available bandwidth accessing my SMB share.

I can confirm that this is a problem from kodi’s SMB client.