0

Need your help with this

package main

import (
    "log"
    "net/http"
)

func main() {
    client := &http.Client{}
    _, err := client.Get("https://www.marathonbet.com/en/")
    if err != nil {
        log.Fatalf("%s\n", err)
    }
}

This always return:Get https://www.marathonbet.com/en/: net/http: TLS handshake timeout exit status 1 I`m try: it and use this lib and do it But nothing works for me.. So, please help me.

Update: In Python 2.7 with requests this works:

s = Session()
r = s.get('https://www.marathonbet.com/en/, verify=False)

But i need do it with go(

UPD: Fixed: Just replase https://www.marathonbet.com/en/ to https://87.117.250.213/en/ and adding skip verify. thx all for help.

Community
  • 1
  • 1
  • 2
    There's nothing wrong with that host that I can see, and it looks fairly well configured. Are you having trouble connecting via IPv6? – JimB Nov 07 '15 at 02:33
  • What happens if you try a different https host? – poolie Nov 07 '15 at 06:48
  • Nope, `https://code.google.com` - works perfect. – Evgeniy Solomanidin Nov 07 '15 at 11:45
  • It would be nice to know if it was an IPv6 problem. Are you using go1.5.1? – JimB Nov 07 '15 at 16:09
  • yep, i use go1.5.1 this can because my provider block this site?i found redirect lin to this site and it`s work, but why i can access to site with Python from normal link? – Evgeniy Solomanidin Nov 07 '15 at 16:19
  • i don`t know how use ipv6. – Evgeniy Solomanidin Nov 07 '15 at 16:21
  • You're going to have to try some debugging on your side to provide more information. Does changing the dns resolver from cgo to netgo change anything? Have you tried connecting using the IPv4 and IPv6 addresses directly, or used a dialer which only calls one protocol (I'm focusing on DNS and IPv6, because you haven't shown anything else that could be different between the GO, and other clients) – JimB Nov 09 '15 at 17:39
  • Fixed, just remove `"https://www.marathonbet.com/en/"` to `"https://87.117.250.213/en/"` and add skip verify – Evgeniy Solomanidin Nov 11 '15 at 16:38
  • 3
    @EvgeniySolomanidin: that's absolutely the wrong solution, since the DNS may change at any point (it goes through cloudflare), and you can't trust the remote server. – JimB Nov 19 '15 at 17:23
  • There does not appear to be anything in particular wrong with your Go code, and indeed I have no problems running that code myself against that host. You may want to consider using [the httptrace package](https://golang.org/pkg/net/http/httptrace/) to trace the request and dump information. – Flowchartsman Jun 24 '21 at 17:00
  • 1
    Please create an explicit answer to your own question so that StackOverflow won't list this as an unanswered question. – MikeSchinkel Jun 25 '21 at 22:21

1 Answers1

2

Here's a more detailed explanation of what's happening. When you call a domain, your HTTP client calls a DNS server. The DNS server responds with the IP of the target server. At this point everything's OK.

If it's an HTTPS connection, then it starts the TLS handshake. Here's how it works.

TLS handshake

And this the point where you experienced the issue. The request was sent but the server didn't answer correctly (or at all). It may be caused by many factors like the server:

  • isn't accessible
  • needs more time to respond
  • can be hidden behind some firewall/proxy that refuses the connection
  • block all requests from your IP/location
  • etc

By providing the skip verify option and providing the explicit IP address, you skips everything I described above. It means:

  • if the server's IP changes your code will stop working
  • if someone perform a man-in-the-middle attach you won't find out about it.

It's hard to find out what's the root cause without a more deep investigation. If you want to find out what's happening, use the httptrace as @Flowchartsman suggested

kabanek
  • 303
  • 3
  • 18