Skip to content

net/http: TLS server on a goroutine won't respond to clients on different goroutines #3220

Closed
@gopherbot

Description

@gopherbot

by elazarl:

To recreate the problem:

$ mkdir $GOPATH/httpstest
$ cd $GOPATH/httpstest
$ cat ->https_test.go
package main

import ("net/http"
        "crypto/tls"
        "testing")

func init() {
        go http.ListenAndServeTLS(":10122", "cert.pem", "key.pem", nil)
}

func TestHttps(t *testing.T) {
        var acceptAllCerts = &tls.Config{InsecureSkipVerify: true}
        client := &http.Client{Transport:&http.Transport{TLSClientConfig:acceptAllCerts}}
        _,err := client.Get("https://localhost:10122/bobo";)
        if err != nil {
                t.Error("can't connect to server",err)
        }
}

$ go test
--- FAIL: TestHttps (0.05 seconds)
        https_test.go:16: can't connect to server Get https://localhost:10122/bobo: dial tcp 127.0.0.1:10122: connection refused
FAIL
exit status 1
FAIL    _/home/vmplanet/gopath/testhttps        0.058s

Other processes can access the http-TLS server.

$ hg id
f4470a54e6db weekly/weekly.2012-03-04

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 11.04
Release:        11.04
Codename:       natty


$ uname -a
Linux ubuntu-vm 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:05:41 UTC 2011 i686 i686
i386 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions