luaxmppprosody-im

How select prefered file transport method?


I have a problem, as I think, with my prosody configuration. When I am sending files (for example photos) more the ~2 or 3 megabytes (as I established experimentally) using Converstions 2.* version (android IM app) it transfers this files using peer to peer connection instead of uploading this file to server and sending a link to my interlocutor. Small files transfers well using http upload. And I couldn't find a reason for such behavior. Here are some lines for http_upload module from my config, that I took from official documentation (where I hadn't found a setup for turning off peer to peer files transfer):

http_upload_file_size_limit = 536870912 -- 512 MB in bytes
http_upload_expire_after = 604800 -- 60 * 60 * 24 * 7
http_upload_quota = 10737418240 -- 10 GB
http_upload_path = "/var/lib/prosody"

And this is my full config: https://pastebin.com/V6DNYrhe


Solution

  • Small files are transferred well using http upload. And I couldn't find a reason for such behavior.

    TL;DR: You put options in the wrong place. The default 1MB limit applies. This is advertised to clients so they know about it and can use more efficient p2p transfer methods for very large files.

    http_upload_path = "/var/lib/prosody"

    This line makes Prosodys data directory public, allowing anyone easy access to all user data. You really don't want to do that. You are lucky you did not put that in the correct section.

    And this is my full config: https://pastebin.com/V6DNYrhe

    "http_upload" is in the global modules_enabled list which will load it onto all VirtualHost(s).

    You have added options to the end of the config file, putting them under a Component section. That makes those options only apply to that Component.

    Thus, the VirtualHost where mod_http_upload is loaded sees no options set and will use the defaults.

    http_upload_file_size_limit = 536870912 -- 512 MB in bytes

    Don't do this. Prosodys built-in HTTP server is not optimized for very large uploads. There is a safety limit on HTTP request size that will cap HTTP upload size limit to 10M to prevent DoS attacks.

    While that limit can be changed, I would strongly suggest you look at https://modules.prosody.im/mod_http_upload_external.html instead.