exercism / cli

A Go based command line tool for exercism.org.
https://exercism.org/docs/using/solving-exercises/working-locally
MIT License
1.33k stars 356 forks source link

Linux: CLI- Configuration Error #701

Closed maeckha closed 6 years ago

maeckha commented 6 years ago

I tried to configure CLI with my token, but got these errors:

[meck@lilsaint ~]$ exercism configure --token=<my token>
Error: The base API URL 'https://api.exercism.io/v1' cannot be reached.

Get https://api.exercism.io/v1/ping: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Sudo:

[meck@lilsaint ~]$ sudo exercism configure --token=<my token>
[sudo] password for meck: 
Error: The base API URL 'https://api.exercism.io/v1' cannot be reached.

Get https://api.exercism.io/v1/ping: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

Troubleshoot:

[meck@lilsaint ~]$ exercism troubleshoot

Troubleshooting Information
===========================

Version
----------------
Current: 3.0.6
Latest:  3.0.6

Operating System
----------------
OS:           linux
Architecture: amd64

Configuration
----------------
Home:      /home/meck
Workspace: /home/meck/exercism (default)
Config:    /home/meck/.config/exercism
API key:   <not configured>
Find your API key at https://exercism.io/my/settings

API Reachability
----------------

GitHub:
    * https://api.github.com
    * [connected]
    * 117.199064ms

Exercism:
    * https://api.exercism.io/v1/ping
    * [connected]
    * 272.994092ms

If you are having trouble please file a GitHub issue at
https://github.com/exercism/exercism.io/issues and include
this information.

Does someone know any solution to this? Thanks in advance!

kytrinyx commented 6 years ago

You should not need sudo.

This is interesting because it says that you're unable to reach the URL:

Get https://api.exercism.io/v1/ping: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

However when you call the troubleshoot command, you are able to connect. It's not fast, but it's less than a second:

Exercism:
    * https://api.exercism.io/v1/ping
    * [connected]
    * 272.994092ms

The timeout in the configure command is 10 seconds, whereas the one in the troubleshoot command is 20, which should not affect this.

You could try this:

exercism configure --token=<your token> --no-verify 

But if this is a timeout problem, you'd probably get a timeout again when calling download.

What does time curl -v https://api.exercism.io/v1/ping return?

maeckha commented 6 years ago

Hi, thanks for your quick response! Your --no-verify suggestion worked and my CLI was set up immediately. But as you predicted, download was canceled.

time curl says this:

time curl -v https://api.exercism.io/v1/ping
*   Trying 54.194.249.254...
* TCP_NODELAY set
* Connected to api.exercism.io (54.194.249.254) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=exercism.io
*  start date: Jul 10 00:00:00 2018 GMT
*  expire date: Aug 10 12:00:00 2019 GMT
*  subjectAltName: host "api.exercism.io" matched cert's "*.exercism.io"
*  issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
*  SSL certificate verify ok.
> GET /v1/ping HTTP/1.1
> Host: api.exercism.io
> User-Agent: curl/7.61.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Mon, 13 Aug 2018 16:01:29 GMT
< Content-Type: application/json; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Server: nginx/1.10.3 (Ubuntu)
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Permitted-Cross-Domain-Policies: none
< Referrer-Policy: strict-origin-when-cross-origin
< ETag: W/"571587439a6fcd390a7214f28e214fae"
< Cache-Control: max-age=0, private, must-revalidate
< Set-Cookie: site_context=normal; domain=.exercism.io; path=/
< Set-Cookie: _exercism_session=ArtZ8hjmEUjoYlBFSSOZkCj46WPY%2F4G98gXHprv6LlOFz4tfW%2Bj7vGr2msKrewJAHXHNGb%2BB65NQ4WweVRknaOX%2FJyNDeZvg9MRF8Q%3D%3D--Q25Iy9ku%2BlH%2Bdzzo--CpsXV1IL%2Bpr%2B8OUDMt63ug%3D%3D; domain=.exercism.io; path=/; HttpOnly
< X-Request-Id: ea33fccd-bf42-49d5-8f2f-5d0d8bf0ae71
< X-Runtime: 0.002527
< 
* Connection #0 to host api.exercism.io left intact
{"status":{"website":true,"database":true}}
real    0m0,283s
user    0m0,028s
sys     0m0,018s
kytrinyx commented 6 years ago

I don't understand how curl gets access quickly, and the CLI does not!

@nywilken have you run into anything like this before?

nywilken commented 6 years ago

Not sure if time is what we want here. As it is reporting time in seconds which also accounts for the the time to display the output to the screen.

@MarkyMarkz if you run the following command you should see numbers closer to what you see when running exercism troubleshoot

curl -w "connect_time: %{time_connect}, appconnect_time: %{time_appconnect}\r\n" -o /dev/null -s https://api.exercism.io/v1/ping

@kytrinyx I haven't seen this issue yet. I can reproduce if I drop the Timeout for the client to 1 second on my machine. I'm going to spend a little time reading this document https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/ to see what I can find.

@MarkyMarkz could you share a little information about your environment OS, DNS,

maeckha commented 6 years ago

I am glad, I´m not the only one irritated by this. @nywilken, your command gives following output:

curl -w "connect_time: %{time_connect}, appconnect_time: %{time_appconnect}\r\n" -o /dev/null -s https://api.exercism.io/v1/ping
connect_time: 0,544756, appconnect_time: 0,711637

I´m using Manjaro with KDE. I should mention that I used Exercism before without problems on the same laptop but with Mint KDE. Kernel: 4.16.18-rt12-MANJARO

Sorry for the noob question, I tried using dig or host for DNS information but those commands were not found neither could I install them. Could you please give me a short explanation in how to provide the DNS information? Thanks to both of you for your work!

arademann commented 6 years ago

Adding nameserver 8.8.8.8 to your /etc/resolv.conf may be a workaround. It worked for me, at least. I had the same problem a few months ago while I was working with Docker. https://github.com/docker/for-win/issues/611

nywilken commented 6 years ago

@arademann thanks for offering that advice - I've seen others report the same solution. But there are a number of users having the same issue #711 and #712.

@MarkyMarkz I've been trying to debug this further and while I haven't confirmed it just yet because I have not setup a debug process for this I believe the issue occurs when we throw auth into the mix; possibly even load on the backend server when making the request. More specifically, with the extra connections being made the http Client is timing out. The timeout is currently set to 10 seconds.

@kytrinyx mentioned building in a flag to allow for setting the timeout at runtime would you be up for testing out that build to help give us more context on the issue?

maeckha commented 6 years ago

@arademann, thank you for your suggestion. Unfortunately it didn´t work.

sudha50 commented 6 years ago

@arademann solution worked for me.

kytrinyx commented 6 years ago

I've opened a pull request to add the configurable http timeout.

Once that gets merged and a cut is released, you will be able to pass a flag --timeout= which will override the default timeout that we use. E.g.

exercism download --track=go --exercise=hello-world --timeout=60
nelsonmfinda commented 5 years ago

Can't download exercise. Image contain error print screen

Troubleshooting Information
===========================

Version
----------------
Current: 3.0.11
Latest:  3.0.11

Operating System
----------------
OS:           linux
Architecture: amd64

Configuration
----------------
Home:      /home/nelsonmfinda
Workspace: /home/nelsonmfinda/exercism
Config:    /home/nelsonmfinda/.config/exercism
API key:   6257*****************************81b

API Reachability
----------------

GitHub:
    * https://api.github.com
    * [connected]
    * 2.69407533s

Exercism:
    * https://api.exercism.io/v1/ping
    * [Get https://api.exercism.io/v1/ping: net/http: TLS handshake timeout]
    * 14.892179342s

If you are having trouble please file a GitHub issue at
https://github.com/exercism/exercism.io/issues and include
this information.
0xtruly commented 4 years ago

Hi I'm getting this error while trying to configure exercism like so exercism configure --token=a********-*****-*****-****-************1 here's the error I get: Error: The base API URL 'https://api.exercism.io/v1' cannot be reached. and

curl https://api.exercism.io/v1/ping:

returns an empty object {}

NobbZ commented 4 years ago

@Segun-Ade what operating system do you use? Please be as exact as possible and mention all virtualization and containerization layers you are aware of.

0xtruly commented 4 years ago

@NobbZ I use a Linux distro called deepin on a Dell latitude e5550 with a quad core processor

0xtruly commented 4 years ago

I tried the command exercism upgrade and got the following errors

Error:

We were not able to upgrade the cli because we encountered an error: Get https://api.github.com/repos/exercism/cli/releases/latest: dial tcp: lookup api.github.com on 192.168.1.1:53: dial udp 192.168.1.1:53: socket: permission denied

Please check the FAQ for solutions to common upgrading issues.

https://exercism.io/faqs

NobbZ commented 4 years ago

@Segun-Ade so your Linux runs natively without any virtualization, that's good, then we don't have any external firewall interfering.

The endpoint URL is correct, despite what others say.

Though I'm wondering, why you get that permission denied on the upgrade.

Currently it looks like some personal firewall that selectively blocks traffic of exercism CLI.

Though I haven't seen those really used on Linux.

Could you perhaps post the full output of exercism troubleshoot (or was it debug?).

Remember to put it between tripple backticks.

0xtruly commented 4 years ago

@NobbZ

Troubleshooting Information

Version

Current: 3.0.13 Latest:

Error: Get https://api.github.com/repos/exercism/cli/releases/latest: dial tcp: lookup api.github.com on [::1]:53: dial udp [::1]:53: socket: permission denied

Call 'exercism upgrade' to get the latest version. See the release notes at https://github.com/exercism/cli/releases/tag/ for details.

Operating System

OS: linux Architecture: amd64

Configuration

Home: /home/segun/snap/exercism/5 Workspace: /home/segun/snap/exercism/5/exercism (default) Config: /home/segun/snap/exercism/5/.config/exercism API key: Find your API key at https://exercism.io/my/settings

API Reachability

GitHub:

Exercism:

If you are having trouble please file a GitHub issue at https://github.com/exercism/exercism.io/issues and include this information.

NobbZ commented 4 years ago

I'm confused by the output you have shown so far…

Sometimes it tries to resolve DNS on a remote (192.168.1.1), sometimes it tries to do on the local system (::1).

Anyway, it seems as if the exercism CLI, or the user who runs it, isn't allowed to do DNS queries.

Perhaps you do not even have an DNS available and you are behind a proxy?

grahamgower commented 4 years ago

I have the same problem. Is there an option to use IPv4 instead?

NobbZ commented 4 years ago

Which problem exactly?

Best is probably to open a new ticket at https://github.com/exercism/exercism and provide all the information you feel relevant after reading this thread.

IPv4 vs IPv6 shouldn't make any differences. Exercism.io itsef has only an A record, no AAAA, so it will be dealt with through IPv4 only anyway.

For your local DNS you need to check your local DNS configuration if you want to change that.

grahamgower commented 4 years ago

I got similar output to above, when running exercism troubleshoot. E.g.

  • [Get https://api.github.com: dial tcp: lookup api.github.com on [::1]:53: dial udp [::1]:53: socket: permission denied]
  • 17.897604ms

I've just checkout out the latest from the git repository and it seems to be fixed now.