User-defined SFTP connection timeout
Problem
The current method of connecting to an SFTP server uses the Jsch library's default timeout behavior, which is 120 seconds. For scenarios where the SFTP server cannot be reached (e.g. the server is only addressable from a local network, which the phone is not connected to), this essentially results in the application hanging until that timeout has passed.
Proposed Solution
This pull request aims to make this connection timeout (optionally) user-configurable. It exposes an option when creating/editing the SFTP database details. The extra information is embedded into the "connection URL" as "query parameters" like so:
Before: sftp://<user>:<password>@<host>:<port>/path/to/initial/directory
After: sftp://<user>:<password>@<host>:<port>?connectTimeout=<###>/path/to/initial/directory
(additional parameters can be added/handled in future, following the typical URL query parameter format)
This additional information is extracted and used, if set, to call the JSch Session.connect(int) method, instead of Session.connect()
Related Issues
NOTE: I have not been successful in building this project locally (not for lack of trying, on both Linux and Windows). As such I do not feel comfortable merging. It would be greatly appreciated if @PhilippC (or another in the community) could try their hand at building/trying this out at their leisure? Thanks in advance.
@SQuIsHY7D3m Does your approval mean you were able to build/test these changes?
thanks for the PR and sorry that I wasn't able to check this for so long. @tenzap has suggested a PR (which is merged already) which greatly simplifies building on different platforms, maybe you want to merge these changes and then do the testing yourself, @hyproman ?
In case build fails due to samsungpass, you also need merge the changes in https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/2
@PhilippC maybe you want to check and merge also the pr in samsungpass https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/2 https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/3 and #2139
Targetframework is not mandatory to update iirc.
Btw the github worflow has a step where it manually patches the files of samsungpass until https://github.com/PhilippC/Xamarin-Samsung-Pass/pull/2 is merged.
Other solution would be to completely remove Samsung pass and use 'Google API for biometric authentication' instead as suggested by samsung engineering team.
Thanks @tenzap and @PhilippC for updates on the build environment and the helpful comments. I was finally able to get the project to build on linux via command line (make).
I've made a few more updates to my contribution; at this point I have tested the signed debug K2P apk as well as the JavaFileStorageTest-AS apk and both seem to work as intended with respect to SFTP connection timeout.
Please let me know if you have a comments or concerns.
It seems there are a few things not quite working 100% correctly. I'll keep working on it. As such please do not merge this yet :) I'll report back with any updates.
@PhilippC I believe I have sufficiently reworked this change-set so that it works consistently with regard to the filechooser and "Recent Databases" functionality.
Please review at your leisure and let me know of any concerns and/or ability to merge. Thanks!
just a quick heads-up on this PR: I wanted to test this thoroughly before merging, and currently I want to get a stable version with targetSdk 31 released first, but it definitely will be merged (if everything works)!
Totally understand 👍
Probably for the better that it wasn't merged.
I had made some assumptions about how android-filechooser worked that didn't turn out to be entirely true. After spending a bunch of time debugging and learning, I have reworked how SftpStorage and android-filechooser interact with each other with respect to URIs with query parameters. This implementation retains the query parameters through all filechooser actions that require an SFTP connection.
I've also cleaned up/consolidated the commits to better reflect the end result.
Guys, do you think this could be merged to master any time soon? I have been checking this pull request a lot :). Thank you
Guys, do you think this could be merged to master any time soon? I have been checking this pull request a lot :). Thank you
I want to get 1.09e published to Play Store before adding more features. Unfortunately this turns out to be much more time consuming than expected, but I think it's on a good way now.
Any plans on merging this to master then? I still suffer from the issue on weekly basis. Thank you :)
Still hoping this would be merged to master Thank you
@hyproman can we close this after merging #2386 ?