{"action":"created","issue":{"url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/364","labels_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/364/labels{/name}","comments_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/364/comments","events_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/364/events","html_url":"https://github.com/sdkman/sdkman-cli/pull/364","id":108898039,"number":364,"title":"Increase curl timeout parameters on sdkman-init.sh","user":{"login":"GsusRecovery","id":12133599,"avatar_url":"https://avatars.githubusercontent.com/u/12133599?v=3","gravatar_id":"","url":"https://api.github.com/users/GsusRecovery","html_url":"https://github.com/GsusRecovery","followers_url":"https://api.github.com/users/GsusRecovery/followers","following_url":"https://api.github.com/users/GsusRecovery/following{/other_user}","gists_url":"https://api.github.com/users/GsusRecovery/gists{/gist_id}","starred_url":"https://api.github.com/users/GsusRecovery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GsusRecovery/subscriptions","organizations_url":"https://api.github.com/users/GsusRecovery/orgs","repos_url":"https://api.github.com/users/GsusRecovery/repos","events_url":"https://api.github.com/users/GsusRecovery/events{/privacy}","received_events_url":"https://api.github.com/users/GsusRecovery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-29T15:45:32Z","updated_at":"2015-10-01T17:22:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sdkman/sdkman-cli/pulls/364","html_url":"https://github.com/sdkman/sdkman-cli/pull/364","diff_url":"https://github.com/sdkman/sdkman-cli/pull/364.diff","patch_url":"https://github.com/sdkman/sdkman-cli/pull/364.patch"},"body":"Increase curl *--connect-timeout* and *--max-time* parameters to a bigger value (15/20 seconds instead of 1 second) to restore acceptable startup time of the bash shell.\r\n\r\nOn my system (ubuntu 14.04.03 x86_64 in Italy) dsn resolution of \"api.sdkman.it\" took a longer time of the expected behaviour (~8 seconds, view Note 1). The curl utility wait entirely this time despite the --max-time 1 option.\r\n\r\nThis lead every shell spawned on the system to hangs until curl return. Note that curl fails without actually download anything (the file ~/.sdkman/var/version is not written), so the behaviour is repeated everytime.\r\n\r\n* Note 1\r\n```bash\r\n$ time curl \"http://api.sdkman.io/app/version\" --connect-timeout 1 --max-time 1\r\ncurl: (28) Resolving timed out after 1510 milliseconds\r\n\r\nreal    0m8.076s\r\nuser    0m0.004s\r\nsys     0m0.011s\r\n```"},"comment":{"url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/comments/144792483","html_url":"https://github.com/sdkman/sdkman-cli/pull/364#issuecomment-144792483","issue_url":"https://api.github.com/repos/sdkman/sdkman-cli/issues/364","id":144792483,"user":{"login":"marcoVermeulen","id":144390,"avatar_url":"https://avatars.githubusercontent.com/u/144390?v=3","gravatar_id":"","url":"https://api.github.com/users/marcoVermeulen","html_url":"https://github.com/marcoVermeulen","followers_url":"https://api.github.com/users/marcoVermeulen/followers","following_url":"https://api.github.com/users/marcoVermeulen/following{/other_user}","gists_url":"https://api.github.com/users/marcoVermeulen/gists{/gist_id}","starred_url":"https://api.github.com/users/marcoVermeulen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcoVermeulen/subscriptions","organizations_url":"https://api.github.com/users/marcoVermeulen/orgs","repos_url":"https://api.github.com/users/marcoVermeulen/repos","events_url":"https://api.github.com/users/marcoVermeulen/events{/privacy}","received_events_url":"https://api.github.com/users/marcoVermeulen/received_events","type":"User","site_admin":false},"created_at":"2015-10-01T17:22:25Z","updated_at":"2015-10-01T17:22:25Z","body":"The reason we introduced the timeout was so the vast majority of users\nwouldn't have to sit waiting for 15 seconds on opening a shell. So simply\nincreasing the timeout is not an option.\n\nFor me it almost feels like we need to make the timeout configurable.\nPerhaps something that ignores the timeout settings all together. We can\nmake this a boolean setting in the config file. Sound like a fair trade?\nOn Thu, 1 Oct 2015 at 17:23, GsusRecovery <notifications@github.com> wrote:\n\n> So it seems to be an issue with curl not honouring it's timeout\n> parameters. We probably need to look at while curl is not doing what it\n> should instead.\n>\n> In my system curl is at version 7.35.0. According to this issue\n> <https://github.com/bagder/curl/issues/383> opened on the github repo of\n> curl, versions after 7.38.0 seems to not suffer anymore from this problem.\n>\n> I've downloaded the latest version (7.45.0) from github and my test\n> confirm the bugfix:\n>\n> # the next command add a 3s delay to all outgoing connections on interface wlan0\n> $ sudo tc qdisc add dev wlan0 root netem delay 3000ms\n> $ time ./curl \"http://api.sdkman.io/app/version\" --connect-timeout 1 --max-time 1\n> curl: (6) name lookup timed out\n>\n> real    0m1.030s\n> user    0m0.014s\n> sys 0m0.024s# remove the fake delay\n> $ sudo tc qdisc del dev wlan0 root netem\n>\n> Note that curl 7.45.0 close the connection after 1 second as expected also\n> with just only one of the two options (--connect-timeout 1 or --max-time 1\n> equally).\n>\n> Also, even though wget is a great tool, it's not an option because most\n> operating systems don't come with it pre-installed. We try and make the\n> barrier of entry to sdkman as low as possible.\n>\n> We can force curl (every bugged version) to work as expected using timeout:\n>\n> $ sudo tc qdisc add dev wlan0 root netem delay 3000ms\n> $ time timeout -s SIGTERM 1 curl \"http://api.sdkman.io/app/version\" --connect-timeout 1 --max-time 1\n>\n> real    0m1.004s\n> user    0m0.012s\n> sys 0m0.006s\n> $ sudo tc qdisc del dev wlan0 root netem\n>\n> How does increasing these timeouts solve this problem?\n>\n> We can consider the options we have (current version, relaxed timeout,\n> fixed curl)\n>\n> For users with a *fast* connection (able to download 'version' file in\n> less than 1 second) it's the same in every case (relaxing timeout does not\n> affect download speed).\n>\n> If we talk about users with a *slow* connection (downloading 'version'\n> file takes longer than 1 second), the options are these:\n>\n>    -\n>\n>    Current version of sdkman-init.sh: everytime a new shell is executed\n>    the command line appears only after curl as returned (in my case after ~8\n>    seconds and i use a lot of shells...). curl never actually download\n>    'version' file so the problem persists (really annoying).\n>    -\n>\n>    Fixed curl (version >7.38.0 or curl executed via timeout): curl wait 1\n>    second before close the connection (as expected) but the 'version' file is\n>    neved downloaded. So the version is never actually checked but every new\n>    shell startup is delayed of 1 second for nothing.\n>    -\n>\n>    Relaxed timeout (15 seconds or a reasonable longer time): the first\n>    time a shell is spawned the startup time is affected by the curl long\n>    download operation (the same everytime the 'version' file is older than 24\n>    hours) but all the following shells for the next 24h are not. sdkman\n>    version control is actually done.\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/sdkman/sdkman-cli/pull/364#issuecomment-144778602>.\n>\n"}}