Golang HTTPS无法处理大数据包

I'm stress testing a simple HTTPS Golang web server which looks like this:

func main() {
    srv := &http.Server{
        Addr:         ":" + port,
        ReadTimeout:  5 * time.Second,
        WriteTimeout: 10 * time.Second,

    mux := http.NewServeMux()
    mux.HandleFunc("/bigpacket", bigpacket)
    srv.Handler = mux

    log.Fatalln(srv.ListenAndServeTLS(certPath+"cert.pem", certPath+"key.pem"))

// Sends 1MB file
func bigpacket(w http.ResponseWriter, r *http.Request) {
    http.ServeFile(w, r, "./bigpacket")

So it's just a very basic server, which returns a 1MB file on the url: /bigpacket. The test I'm running does 1000 requests per second (so about 1GB per second is send over the connection) for 30 seconds.

When testing this, only about 30% of the requests are successful! However, when I switch to HTTP (by using log.Fatalln(srv.ListenAndServe())) all requests are successful.. (100%) Could these results be correct? Has HTTPS that much overhead over HTTP?

These are the errors I get:

read tcp> read: connection reset by peer
unexpected EOF
Get unexpected EOF
read tcp> read: connection reset by peer
Get read tcp> read: connection reset by peer
Get write tcp> write: broken pipe
Get http2: no cached connection was available
Get read tcp> read: connection reset by peer
read tcp> read: connection reset by peer
Get write tcp> write: connection reset by peer
read tcp> read: connection reset by peer
Get write tcp> write: connection reset by peer
Get write tcp> write: broken pipe
read tcp> read: connection reset by peer
read tcp> read: connection reset by peer
read tcp> read: connection reset by peer
Get read tcp
doutuan6158 不是没有巨型帧,只有普通的数据包发送了一个大文件(1MB)。好的,谢谢,我只是不太希望TLS开销这么大!
3 年多之前 回复
dongshengheng1013 您没有在此处包含有关如何配置“大数据包”的任何信息(您是说巨型帧吗?),但实际上发出的请求数量超出服务器的处理能力。如果1000req/s使HTTP连接饱和,则根本无法使用HTTPS发出相同数量的请求。
接近 4 年之前 回复
donglian6625 每个新会话都需要完整的SSL协商。仅通过SSL证书就可以提供约1-10MB/s的额外网络带宽(因此,仅文件传输的0.1%到1%)。它还增加了一些往返和一些公共密钥加密,这很可能是最沉重的打击。
接近 4 年之前 回复
Csdn user default icon
Golang HTTPS / TLS POST客户端/服务器

<div class="post-text" itemprop="text"> <p>I have written a simple client/server in Go that will do an HTTP GET over TLS, but I'm trying to also make it capable of doing an HTTP POST over TLS.</p> <p>In the example below <code>index.html</code> just contains the text <code>hello</code>, and the HTTP GET is working fine. I want the client to get the HTTP GET and write back, <code>hello world</code> to the server.</p> <p>client</p> <pre><code>package main import ( "crypto/tls" "fmt" "io/ioutil" "net/http" "strings" ) func main() { link := "" tr := &amp;http.Transport{ TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, } client := &amp;http.Client{Transport: tr} response, err := client.Get(link) if err != nil { fmt.Println(err) } defer response.Body.Close() content, _ := ioutil.ReadAll(response.Body) s := strings.TrimSpace(string(content)) fmt.Println(s) // out := s + " world" // Not working POST... // resp, err := client.Post(link, "text/plain", &amp;out) } </code></pre> <p>server</p> <pre><code>package main import ( "fmt" "log" "net/http" ) func main() { http.HandleFunc("/static/", func (w http.ResponseWriter, r *http.Request) { fmt.Println("Got connection!") http.ServeFile(w, r, r.URL.Path[1:]) }) log.Fatal(http.ListenAndServeTLS(":443", "server.crt", "server.key", nil)) } </code></pre> <p>I also currently have nothing to handle the POST on the server side, but I just want it to print it out to the screen so when I run the client I will see the server print <code>hello world</code>.</p> <p>How should I fix my client code to do a proper POST? And what should the corresponding server code look like to accept the POST? Any help would be appreciated, I'm having trouble finding HTTPS/TLS POST examples.</p> </div>

在GoLang UDP服务器中获取分段数据包

<div class="post-text" itemprop="text"> <p>I need to implement a udp listener in go to read incoming packets from a port and parse them as json. The problem is I'm getting fragmented packets which breaks parsing as they're incomplete json.</p> <pre><code>const BufferSize = 15214400 func udpListener(ip []byte, port int) { addr := net.UDPAddr{IP: ip, Port: port, Zone: ""} ServerConn, err := net.ListenUDP("udp", &amp;addr) if err != nil { log.Panicln(err.Error()) } ServerConn.SetReadBuffer(BufferSize) defer ServerConn.Close() buffer := make([]byte, BufferSize) for { buffLen, senderAddress, err := ServerConn.ReadFromUDP(buffer) if err != nil { log.Errorln("Error occurred while read data from UDP: " + err.Error()) continue } go handleUdpDatagram(buffLen, buffer, senderAddress.String()) } } func handleUdpDatagram(buffLen int, buffer []byte, senderAddress string) { var jsonData map[string]interface{} if err := json.Unmarshal(buffer[0:buffLen], &amp;jsonData); err != nil { log.Errorln("Error occurred while parsing data: " + data) return } } </code></pre> <p>The packets chopped at a random number of bytes and sent in next read. The size of chopped packets is not constant, I'm getting other packets intact with bigger sizes.</p> <p>Sample packet:</p> <pre><code>{"_id":"5c7c366e29c0094fcb03306e","index":0,"guid":"04fbc039-7fb4-4b3f-9722-60a0617b5469","isActive":true,"balance":"$3,431.05","picture":"http://placehold.it/32x32","age":25,"eyeColor":"green","name":"Reynolds Rodgers","gender":"male","company":"BITENDREX","email":"reynoldsrodgers@bitendrex.com","phone":"+1 (905) 547-2873","address":"778 Mermaid Avenue, Draper, Northern Mariana Islands, 4983","about":"Qui ad velit ut irure eu veniam laborum nulla fugiat magna nostrud irure in laboris. Laborum commodo enim Lorem anim id. Ex cupidatat do ad labore cillum cillum aute cillum. Incididunt velit duis nostrud deserunt anim. Aliqua aute commodo magna in deserunt reprehenderit consectetur aliquip ea proident. Ullamco deserunt qui aliqua ad mollit commodo enim pariatur enim labore cillum. Eu deserunt quis adipisicing nisi sint magna proident voluptate fugiat eiusmod ut nostrud exercitation sit. ","registered":"2018-11-14T06:24:10 -06:-30","latitude":-70.393932,"longitude":-95.507978,"tags":["esse","voluptate","eu","enim","ullamco","aute","velit"],"friends":[{"id":0,"name":"Wendi Graves"},{"id":1,"name":"Hogan Bean"},{"id":2,"name":"Garrison Bennett"}],"greeting":"Hello, Reynolds Rodgers! You have 2 unread messages.","favoriteFruit":"banana"} </code></pre> <p>When I send this packet, the listener receives it in 2 fragments</p> <pre><code>time="2019-03-04T01:51:47+05:30" level=error msg="Error occurred while parsing data: im\",\"ullamco\",\"aute\",\"velit\"],\"friends\":[{\"id\":0,\"name\":\"Wendi Graves\"},{\"id\":1,\"name\":\"Hogan Bean\"},{\"id\":2,\"name\":\"Garrison Bennett\"}],\"greeting\":\"Hello, Reynolds Rodgers! You have 2 unread messages.\",\"favoriteFruit\":\"banana\"} \"male\",\"company\":\"BITENDREX\",\"email\":\"reynoldsrodgers@bitendrex.com\",\"phone\":\"+1 (905) 547-2873\",\"address\":\"778 Mermaid Avenue, Draper, Northern Mariana Islands, 4983\",\"about\":\"Qui ad velit ut irure eu veniam laborum nulla fugiat magna nostrud irure in laboris. Laborum commodo enim Lorem anim id. Ex cupidatat do ad labore cillum cillum aute cillum. Incididunt velit duis nostrud deserunt anim. Aliqua aute commodo magna in deserunt reprehenderit consectetur aliquip ea proident. Ullamco deserunt qui aliqua ad mollit commodo enim pariatur enim labore cillum. Eu deserunt quis adipisicing nisi sint magna proident voluptate fugiat eiusmod ut nostrud exercitation sit. \",\"registered\":\"2018-11-14T06:24:10 -06:-30\",\"latitude\":-70.393932,\"longitude\":-95.507978,\"tags\":[\"esse\",\"voluptate\",\"eu\",\"en error: invalid character 'i' looking for beginning of value" time="2019-03-04T01:51:47+05:30" level=error msg="Error occurred while parsing data: im\",\"ullamco\",\"aute\",\"velit\"],\"friends\":[{\"id\":0,\"name\":\"Wendi Graves\"},{\"id\":1,\"name\":\"Hogan Bean\"},{\"id\":2,\"name\":\"Garrison Bennett\"}],\"greeting\":\"Hello, Reynolds Rodgers! You have 2 unread messages.\",\"favoriteFruit\":\"banana\"} error: invalid character 'i' looking for beginning of value" </code></pre> </div>

代理golang https

<div class="post-text" itemprop="text"> <p>i am trying to make one get in <a href="https://www.google.com" rel="nofollow noreferrer">https://www.google.com</a> using proxy with authentication, i already passing header parameter </p> <blockquote> <p>Proxy-Authorization</p> </blockquote> <p>but proxy server return </p> <blockquote> <p>Proxy Authentication Required</p> </blockquote> <p>code:</p> <pre><code>package main import ( "crypto/tls" "encoding/base64" "fmt" "io/ioutil" "net/http" "net/url" "os" ) func main() { req, _ := http.NewRequest("GET", "https://www.google.com.br", nil) req.Header.Set("Host", "www.google.com.br") proxyURL := url.URL{ Host: "IP-HERE:PORT-HEERE"} transport := &amp;http.Transport{ Proxy: http.ProxyURL(&amp;proxyURL), TLSClientConfig: &amp;tls.Config{}, } client := &amp;http.Client{Transport: transport} req.RequestURI = "" auth := fmt.Sprintf("USER:PASSWORD") basic := "Basic " + base64.StdEncoding.EncodeToString([]byte(auth)) req.Header.Add("Proxy-Authorization", basic) resp, err := client.Do(req) if err != nil { fmt.Printf("erro: %s", err) } fmt.Printf("code: %s", resp.StatusCode) htmlData, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) os.Exit(1) } fmt.Println(os.Stdout, string(htmlData)) } </code></pre> <p>I have to pass another parameter?</p> <p>When i perform one get in <a href="http://www.google.com.br" rel="nofollow noreferrer">http://www.google.com.br</a>, without https.. proxy authentication with success. why?</p> </div>


<div class="post-text" itemprop="text"> <p>I have a server which has a rest API running over https. I want to make a call to this rest api in my application which is running in different port but since this is over https I am getting </p> <pre><code>Post https://localhost:8080/api/v1/myapi: x509: certificate signed by unknown authority </code></pre> <p>I have 2 files pulic_key.pem and private_key which can used to verify the certificate. How can verify certificate while sending rest request using golang? I am using <code>&amp;http.Client{}</code> to send a rest request. Here is what I am doing to ignore the certificate right now.</p> <pre><code>tr := &amp;http.Transport{ TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, } client := &amp;http.Client{Transport: tr} </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I am able to do a http or https client request without setting up a proxy, </p> <pre><code>enter code here tr := &amp;http.Transport{ TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, } client := &amp;http.Client{} client.Transport = tr request, err := http.NewRequest("HEAD", "http://www.???.com", nil) request.Header.Set("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36") resp, err := client.Do(request) if err != nil { log.Fatalln(err) return } defer resp.Body.Close() httpcode = resp.Status </code></pre> <p>This script is working ok, I get a 200 ok when I request https url, but if I set up proxy , the script:</p> <pre><code>proxyString := "https://47.91.179.xxx:443" proxyUrl, _ := url.Parse(proxyString) tr := &amp;http.Transport{ Proxy: http.ProxyURL(proxyUrl), TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, } client := &amp;http.Client{} client.Transport = tr .................... </code></pre> <p>I always get "Bad request", I read docs: <a href="https://golang.org/pkg/net/http/" rel="nofollow noreferrer">https://golang.org/pkg/net/http/</a>:</p> <p>........... Starting with Go 1.6, the http package has transparent support for the HTTP/2 protocol when using HTTPS. Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) or Server.TLSNextProto (for servers) to a non-nil, empty map. Alternatively, the following GODEBUG environment variables are currently supported: ..............</p> <p>So, I tried to stop http2:</p> <pre><code>tr := &amp;http.Transport{ Proxy: http.ProxyURL(proxyUrl), //Proxy: http.ProxyFromEnvironment, TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true}, TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper), } </code></pre> <p>same problem, "Bad request". I tried os.Setenv("HTTPS_PROXY", "47.91.???.???:443"), It is the same result. This is logged in server:</p> <pre><code>{S;}{S;}-{S;}07/Mar/2017:17:01:47 +0800{S;}CONNECT www.panpacific.com:443 HTTP/1.1{S;}400{S;}173{S;}340{S;}-{S;}-{S;}-{S;}-{S;}-{S;}www.panpacific.com </code></pre> <p>So, Does golang support https client request via proxy? How do I get correct results?</p> </div>

golang http处理大文件上传

<div class="post-text" itemprop="text"> <p>I'm using the golang <code>net/http</code> package to construct a webserver.And now I have to handle big file upload which means that the server may get request with <code>Expect: 100 Continue</code>.I will not send response to the client until all data has been received.However every time I finished one request and return, the golang will send a response back by default,How can i implement this? </p> </div>


<div class="post-text" itemprop="text"> <p>currently I try to reimplement a C application in go. Part of the C application is to send a string to a multicast group. This produces the following packet captured via tcpdump:</p> <pre><code>00000000 d4 c3 b2 a1 02 00 04 00 00 00 00 00 00 00 00 00 |................| 00000010 ff ff 00 00 01 00 00 00 14 81 06 56 47 2c 01 00 |...........VG,..| 00000020 46 00 00 00 46 00 00 00 33 33 00 02 10 01 04 ce |F...F...33......| 00000030 ef ca fe 1a 86 dd 60 00 00 00 00 10 11 01 fe 80 |......`.........| 00000040 00 00 00 00 00 00 06 ce ef ff fe ca fe 1a ff 02 |................| 00000050 00 00 00 00 00 00 00 00 00 00 00 02 10 01 be 8f |................| 00000060 03 e9 00 10 99 68 6e 6f 64 65 69 6e 66 6f |.....hnodeinfo| </code></pre> <p>I tried to replicate the behavior with the following code:</p> <pre><code>const MultiCastGroup string = "ff02:0:0:0:0:0:2:1001" const Port int = 1001 const Proto string = "udp6" const MaxDataGramSize int = 8192 var announcedAddr = &amp;net.UDPAddr{IP: net.ParseIP(MultiCastGroup), Port: Port} buf := []byte("nodeinfo") unicastConn, _ := net.ListenUDP(Proto, &amp;net.UDPAddr{IP: net.IPv6zero, Port: 0}) unicastConn.WriteToUDP(buf, announcedAddr) </code></pre> <p>But the I don't think that it is working, because all I can capture from this via tcpdump is:</p> <pre><code>00000000 d4 c3 b2 a1 02 00 04 00 00 00 00 00 00 00 00 00 |................| 00000010 ff ff 00 00 01 00 00 00 |........| 00000018 </code></pre> <p>It doesn't seem that the packet is even send. I tried this on a Debian Wheezy machine. Did anyone if you encounter a similar problem with golang and UDP?</p> <p>Thanks in advance</p> </div>


<div class="post-text" itemprop="text"> <p>I would like to craft custome TCP packets using gopacket and then send them using raw sockets.</p> <p>Here is a short and readable example go program that demonstrates what I'd like to do:</p> <pre><code>package main import ( "code.google.com/p/gopacket" "code.google.com/p/gopacket/examples/util" "code.google.com/p/gopacket/layers" "log" "net" ) func main() { defer util.Run()() // XXX create tcp/ip packet srcIP := net.ParseIP("") dstIP := net.ParseIP("") //srcIPaddr := net.IPAddr{ // IP: srcIP, //} dstIPaddr := net.IPAddr{ IP: dstIP, } ipLayer := layers.IPv4{ SrcIP: srcIP, DstIP: dstIP, Protocol: layers.IPProtocolTCP, } tcpLayer := layers.TCP{ SrcPort: layers.TCPPort(666), DstPort: layers.TCPPort(22), SYN: true, } tcpLayer.SetNetworkLayerForChecksum(&amp;ipLayer) buf := gopacket.NewSerializeBuffer() opts := gopacket.SerializeOptions{ FixLengths: true, ComputeChecksums: true, } err := gopacket.SerializeLayers(buf, opts, &amp;ipLayer, &amp;tcpLayer) if err != nil { panic(err) } // XXX end of packet creation // XXX send packet ipConn, err := net.ListenPacket("ip4:tcp", "") if err != nil { panic(err) } _, err = ipConn.WriteTo(buf.Bytes(), &amp;dstIPaddr) if err != nil { panic(err) } log.Print("packet sent! ") } </code></pre> <p>However running this program doesn't work... the SerializeLayer fails. Here's the panic:</p> <blockquote> <p>panic: invalid src IP</p> <p>goroutine 16 [running]: runtime.panic(0x5bb020, 0xc2090723e0) /home/human/golang-empire/go/src/pkg/runtime/panic.c:279 +0xf5 main.main() /home/human/golang-empire/gopkg/src/github.com/david415/HoneyBadger/packetSendTest.go:41 +0x464</p> <p>goroutine 19 [finalizer wait]: runtime.park(0x413cc0, 0x7bc6c0, 0x7bb189) /home/human/golang-empire/go/src/pkg/runtime/proc.c:1369 +0x89 runtime.parkunlock(0x7bc6c0, 0x7bb189) /home/human/golang-empire/go/src/pkg/runtime/proc.c:1385 +0x3b runfinq() /home/human/golang-empire/go/src/pkg/runtime/mgc0.c:2644 +0xcf runtime.goexit() /home/human/golang-empire/go/src/pkg/runtime/proc.c:1445</p> </blockquote> </div>


<div class="post-text" itemprop="text"> <p>I have a little problem. I want to receive and write udp packets with a DialUDP function. The problem is that it only can write and not receive udp packets (i think). How can i send a packet and let the program wait on a respond from the server?</p> <p>my code:</p> <pre><code>if programPacketType == "udp"{ server,err := net.ResolveUDPAddr("udp4", programAddressInput) checkError(err) lServer, err := net.ResolveUDPAddr("udp4", programLocalAddressInput) checkError(err) conn, err := net.DialUDP("udp4", server, lServer) checkError(err) i := 0 for { msg := strconv.Itoa(i) i++ buf := []byte(msg) _,err := conn.Write(buf) if err != nil { fmt.Println(msg, err) } fmt.Println("sended:", i, "to connected server") time.Sleep(time.Second * 1) } } </code></pre> <p>thanks.</p> <p>(Pls ignore grammatical mistakes,)</p> </div>

如何在Golang Web服务器上设置HTTPS?

<div class="post-text" itemprop="text"> <p>I'm reading <a href="https://www.kaihag.com/https-and-go/" rel="nofollow noreferrer">https://www.kaihag.com/https-and-go/</a> and bought an SSL certificate from Comodo which they emailed me a <code>.zip</code> file. All of the files I have so far look like this</p> <pre><code>csr.pem private-key.pem website.com.crt website.com.ca-bundle website.com.zip </code></pre> <p>The above website wants me to concatenate 3 <code>.pem</code> files which I don't have. Incidentally what is the reason the <code>.pem</code> files need to concatenated? Using the above files which haven't been modified, how can https be set up on a golang webserver?</p> </div>


<div class="post-text" itemprop="text"> <p>I have the following:</p> <ol> <li>Background image (bi)</li> <li>Image1 (i1)</li> <li>Image3 (i2)</li> </ol> <p>I want to position i1 and i2 over bi with some angle and then produce a final image. I have x and y axis value for i1 and i2 and their expected rotation angle. i1 and i2 may partially overlay on each other. but I have z index for i1 and i2 to know, if in case they overlap then who will be in foreground.</p> <p>I am trying to achieve this in Golang.<br> <a href="http://golang.org/doc/articles/image_draw.html" rel="nofollow">http://golang.org/doc/articles/image_draw.html</a> seems to do this. Anyone knows any similar example of code, that may help. Or can you show me couple of lines in Golang as a pseudo program?</p> <p>Thanks.</p> </div>


<div class="post-text" itemprop="text"> <p>I have a channel which stores received data, I want to process it when one of following conditions is met:<br> 1, the channel reaches its capacity.<br> 2, the timer is fired since last process.</p> <p>I saw the post <a href="https://stackoverflow.com/questions/25657207/golang-how-to-know-a-buffered-channel-is-full">Golang - How to know a buffered channel is full</a></p> <p><strong>Update:</strong></p> <p>I inspired from that post and OneOfOne's advice, here is the <a href="https://play.golang.org/p/byalcxHAu3" rel="nofollow noreferrer">play</a> :</p> <pre><code>package main import ( "fmt" "math/rand" "time" ) var c chan int var timer *time.Timer const ( capacity = 5 timerDration = 3 ) func main() { c = make(chan int, capacity) timer = time.NewTimer(time.Second * timerDration) go checkTimer() go sendRecords("A") go sendRecords("B") go sendRecords("C") time.Sleep(time.Second * 20) } func sendRecords(name string) { for i := 0; i &lt; 20; i++ { fmt.Println(name+" sending record....", i) sendOneRecord(i) interval := time.Duration(rand.Intn(500)) time.Sleep(time.Millisecond * interval) } } func sendOneRecord(record int) { select { case c &lt;- record: default: fmt.Println("channel is full !!!") process() c &lt;- record timer.Reset(time.Second * timerDration) } } func checkTimer() { for { select { case &lt;-timer.C: fmt.Println("3s timer ----------") process() timer.Reset(time.Second * timerDration) } } } func process() { for i := 0; i &lt; capacity; i++ { fmt.Println("process......", &lt;-c) } } </code></pre> <p>This seems to work fine, but I have a concern, I want to block the channel writing from other goroutine when process() is called, is the code above capable to do so? Or should I add a mutex at the beginning of the process method?</p> <p>Any elegant solution?</p> </div>


<div class="post-text" itemprop="text"> <p>i am trying to make https request with golang. </p> <pre><code>conf := &amp;tls.Config{ InsecureSkipVerify: true, MinVersion:tls.VersionTLS10, } //TLS connection tlsCon, err := tls.Dial("tcp", "youtube.com:443", conf) if err != nil { fmt.Println("SSL Error : " + err.Error()) return } defer tlsCon.Close() state := tlsCon.ConnectionState() fmt.Println("SSL ServerName : " + state.ServerName) fmt.Println("SSL Handshake : ", state.HandshakeComplete) fmt.Println("SSL Mutual : ", state.NegotiatedProtocolIsMutual) request = ' CONNECT youtube.com:443 HTTP/1.1 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0 Proxy-Connection: close Connection: close Host: youtube.com:443 ' n, err = io.WriteString(tlsCon, request) if err != nil { fmt.Println("SSL Write error :", err.Error(), n) } n, err = tlsCon.Read(data) if err != nil { fmt.Println("SSL Read error : " + err.Error()) return } </code></pre> <p>this is my code , state.HandshakeComplete, state.NegotiatedProtocolIsMutual returns true and state.ServerName returns = ''</p> <p>when i write data to tls connection no error returns also tls connection never reply my request.</p> <p>any help appricated. thanks.</p> </div>


<div class="post-text" itemprop="text"> <p>I am running a https web server in go. I am testing it using a angular web app (Chrome browser) that makes ajax calls to the web server. </p> <p>If I keep hitting the web server continuously everything seems working. But whenever I leave it idle for sometime and hit the web server the ajax call from browser doesn't get a response. Almost always I see this log line in my server log.</p> <p><code>2016/01/16 04:06:47.006977 http: TLS handshake error from EOF</code></p> <p>I can confirm that the IP address is my IP address. </p> <p>I am starting my https server like this:</p> <pre><code>r := mux.NewRouter() r.HandleFunc("/status", handleStatus) setUpLoginEndpoint(&amp;cfg.Session, r) setUpLogoutEndpoint(cfg.Session.CookieName, r) setUpChangePasswordEndpoint(cfg.Session.CookieName, r) setUpMetricSinkEndpoint(cfg.Metric.SinkApiKey, r) setUpMetricQueryEndpoint(cfg.Session.CookieName, r) http.ListenAndServeTLS(":443", "../cert.pem", "../keys.pem", &amp;Server{r}) </code></pre> <p>I can confirm that I am closing the request body in every handler using defer r.Body.Close().</p> <p>I am using go 1.5.2. </p> <p>Any help would be appreciated.</p> <p>Regards,</p> <p>Sathya</p> </div>


<div class="post-text" itemprop="text"> <p>I am currently writing a GoLang website and would like to add SSL soon. My question is what are the advantages/disadvantages of using the built-in Golang SSL packages or should/can I just do SSL with the nginx when I use it for the reverse proxy?</p> </div>


<div class="post-text" itemprop="text"> <p>I have 5 huge (4 million rows each) logfiles that I process in Perl currently and I thought I may try to implement the same in Go and its concurrent features. So, being very inexperienced in Go, I was thinking of doing as below. Any comments on the approach will be greatly appreciated. Some rough pseudocode:</p> <pre><code>var wg1 sync.WaitGroup var wg2 sync.WaitGroup func processRow (r Row) { wg2.Add(1) defer wg2.Done() res = &lt;process r&gt; return res } func processFile(f File) { wg1.Add(1) open(newfile File) defer wg1.Done() line = &lt;row from f&gt; result = go processRow(line) newFile.Println(result) // Write new processed line to newFile wg2.Wait() newFile.Close() } func main() { for each f logfile { go processFile(f) } wg1.Wait() } </code></pre> <p>So, idea is that I process these 5 files concurrently and then all rows of each file will in turn also be processed concurrently.</p> <p>Will that work?</p> </div>


<div class="post-text" itemprop="text"> <p>In GoLang I'm using NewSingleHostReverseProxy to preform a reverse proxy, however I need to confirm the SSL certificates of the host site, to make sure I have the correct secure certificate... any ideas how I should do this? Should I be doing this with the handler or transport? I'm new to GoLang and still getting my head around it. Thanks</p> <pre><code>proxy := httputil.NewSingleHostReverseProxy(&amp;url.URL{ Scheme: "https", Host: "sha256.badssl.com", }) http.ListenAndServe("", proxy) </code></pre> </div>


<div class="post-text" itemprop="text"> <p>I'm currently trying to read in a file with 200+ columns and 1000+ rows. I use the following code: </p> <pre><code>var result []string file, err := os.Open("t8.txt") if (err != nil) { fmt.Println(err) } defer file.Close() scan := bufio.NewScanner(file) for scan.Scan() { result = append(result, scan.Text()) } fmt.Println(scan.Err()) //token too long </code></pre> <p>However when I print out the results, all I get is the first line because it says the token is too long. When I try it on smaller files, it works fine. Is there a way in Golang that I could scan in large files? </p> </div>


<div class="post-text" itemprop="text"> <p>I'm writing a simple program in Golang to capture TCP/IP packets using raw sockets:</p> <pre><code>package main import ( "fmt" "log" "net" ) func main() { netaddr, err := net.ResolveIPAddr("ip", "") if err != nil { log.Fatal(err) } conn, err := net.ListenIP("ip:tcp", netaddr) if err != nil { log.Fatal(err) } packet := make([]byte, 64*1024) numPackets := 0 totalLen := 0 for { packetLen, _, err := conn.ReadFrom(packet) if err != nil { log.Fatal(err) } dataOffsetWords := (packet[12] &amp; 0xF0) &gt;&gt; 4 dataOffset := 4 * dataOffsetWords payload := packet[dataOffset:packetLen] numPackets += 1 totalLen += len(payload) fmt.Println("Num packets:", numPackets, ", Total len:", totalLen) } } </code></pre> <p>When I compare the number of packets which the program receives and the total amount of data they contain to the number of packets Wiresharks sees and the total data transmitted, I know I've lost 15-30 % of all packets and data on every run.</p> <p>Why?</p> <p>The only thing that comes to my mind is that the application is not fast enough to receive the packets, but that's odd. (I'm communicating on localhost and sending ~ 17 MB of data.) Goreplay however uses something similar and works.</p> <p>The traffic I'm receiving is created by <code>curl</code>-ing onto a locally running Python server (<code>http.server</code>) and sending a huge file in the request body. The Python server downloads the whole body successfully.</p> </div>


软件测试2小时入门,让您快速了解软件测试基本知识,有系统的了解; SQL一小时,让您快速理解和掌握SQL基本语法 jmeter性能测试 ,让您快速了解主流来源性能测试工具jmeter 测试管理工具-禅道,让您快速学会禅道的使用,学会测试项目、用例、缺陷的管理、



Java 最常见的 200+ 面试题:面试必备

这份面试清单是从我 2015 年做了 TeamLeader 之后开始收集的,一方面是给公司招聘用,另一方面是想用它来挖掘在 Java 技术栈中,还有那些知识点是我不知道的,我想找到这些技术盲点,然后修复它,以此来提高自己的技术水平。虽然我是从 2009 年就开始参加编程工作了,但我依旧觉得自己现在要学的东西很多,并且学习这些知识,让我很有成就感和满足感,那所以何乐而不为呢? 说回面试的事,这份面试...




总课时80+,提供源码和相关资料 本课程从Python零基础到纯Python项目实战。内容详细,案例丰富,覆盖了Python知识的方方面面,学完后不仅对Python知识有个系统化的了解,让你从Python小白变编程大牛! 课程包含: 1.python安装 2.变量、数据类型和运算符 3.选择结构 4.循环结构 5.函数和模块 6.文件读写 7.了解面向对象 8.异常处理


获取讲师答疑方式: 在付费视频第一节(触摸命令_ALL)片头有二维码及加群流程介绍 限时福利 原价99元,今日仅需39元!购课添加小助手(微信号:csdn590)按提示还可领取价值800元的编程大礼包! 讲师介绍: 苏奕嘉&nbsp;前阿里UC项目工程师 脚本开发平台官方认证满级(六级)开发者。 我将如何教会你通过【定制脚本】赚到你人生的第一桶金? 零基础程序定制脚本开发课程,是完全针对零脚本开发经验的小白而设计,课程内容共分为3大阶段: ①前期将带你掌握Q开发语言和界面交互开发能力; ②中期通过实战来制作有具体需求的定制脚本; ③后期将解锁脚本的更高阶玩法,打通任督二脉; ④应用定制脚本合法赚取额外收入的完整经验分享,带你通过程序定制脚本开发这项副业,赚取到你的第一桶金!


本课程为HoloLens2开发入门教程,讲解部署开发环境,安装VS2019,Unity版本,Windows SDK,创建Unity项目,讲解如何使用MRTK,编辑器模拟手势交互,打包VS工程并编译部署应用到HoloLens上等。






设置复位开关。当按下复位开关时,秒表清零并做好计时准备。在任何情况下只要按下复位开关,秒表都要无条件地进行复位操作,即使是在计时过程中也要无条件地进行清零操作。 设置启/停开关。当按下启/停开关后,将




董付国系列教材《Python程序设计基础》、《Python程序设计(第2版)》、《Python可以这样学》配套视频,讲解Python 3.5.x和3.6.x语法、内置对象用法、选择与循环以及函数设计与使用、lambda表达式用法、字符串与正则表达式应用、面向对象编程、文本文件与二进制文件操作、目录操作与系统运维、异常处理结构。

计算机操作系统 第三版.pdf

计算机操作系统 第三版 本书全面介绍了计算机系统中的一个重要软件——操作系统(OS),本书是第三版,对2001年出版的修订版的各章内容均作了较多的修改,基本上能反映当前操作系统发展的现状,但章节名称基

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Vue.js 2.0之全家桶系列视频课程

基于新的Vue.js 2.3版本, 目前新全的Vue.js教学视频,让你少走弯路,直达技术前沿! 1. 包含Vue.js全家桶(vue.js、vue-router、axios、vuex、vue-cli、webpack、ElementUI等) 2. 采用笔记+代码案例的形式讲解,通俗易懂


本套课程的设计完全是为初学者量身打造,课程内容由浅入深,课程讲解通俗易懂,代码实现简洁清晰。通过本课程的学习,学员能够入门微信公众平台开发,能够胜任企业级的订阅号、服务号、企业号的应用开发工作。 通过本课程的学习,学员能够对微信公众平台有一个清晰的、系统性的认识。例如,公众号是什么,它有什么特点,它能做什么,怎么开发公众号。 其次,通过本课程的学习,学员能够掌握微信公众平台开发的方法、技术和应用实现。例如,开发者文档怎么看,开发环境怎么搭建,基本的消息交互如何实现,常用的方法技巧有哪些,真实应用怎么开发。


【为什么学爬虫?】 &nbsp; &nbsp; &nbsp; &nbsp;1、爬虫入手容易,但是深入较难,如何写出高效率的爬虫,如何写出灵活性高可扩展的爬虫都是一项技术活。另外在爬虫过程中,经常容易遇到被反爬虫,比如字体反爬、IP识别、验证码等,如何层层攻克难点拿到想要的数据,这门课程,你都能学到! &nbsp; &nbsp; &nbsp; &nbsp;2、如果是作为一个其他行业的开发者,比如app开发,web开发,学习爬虫能让你加强对技术的认知,能够开发出更加安全的软件和网站 【课程设计】 一个完整的爬虫程序,无论大小,总体来说可以分成三个步骤,分别是: 网络请求:模拟浏览器的行为从网上抓取数据。 数据解析:将请求下来的数据进行过滤,提取我们想要的数据。 数据存储:将提取到的数据存储到硬盘或者内存中。比如用mysql数据库或者redis等。 那么本课程也是按照这几个步骤循序渐进的进行讲解,带领学生完整的掌握每个步骤的技术。另外,因为爬虫的多样性,在爬取的过程中可能会发生被反爬、效率低下等。因此我们又增加了两个章节用来提高爬虫程序的灵活性,分别是: 爬虫进阶:包括IP代理,多线程爬虫,图形验证码识别、JS加密解密、动态网页爬虫、字体反爬识别等。 Scrapy和分布式爬虫:Scrapy框架、Scrapy-redis组件、分布式爬虫等。 通过爬虫进阶的知识点我们能应付大量的反爬网站,而Scrapy框架作为一个专业的爬虫框架,使用他可以快速提高我们编写爬虫程序的效率和速度。另外如果一台机器不能满足你的需求,我们可以用分布式爬虫让多台机器帮助你快速爬取数据。 &nbsp; 从基础爬虫到商业化应用爬虫,本套课程满足您的所有需求! 【课程服务】 专属付费社群+每周三讨论会+1v1答疑




&nbsp; &nbsp; &nbsp; &nbsp; 本课程为Python数据挖掘方向的入门课程,课程主要以真实数据为基础,详细介绍数据挖掘入门的流程和使用Python实现pandas与numpy在数据挖掘方向的运用,并深入学习如何运用scikit-learn调用常用的数据挖掘算法解决数据挖掘问题,为进一步深入学习数据挖掘打下扎实的基础。

2019 AI开发者大会

2019 AI开发者大会(AI ProCon 2019)是由中国IT社区CSDN主办的AI技术与产业年度盛会。多年经验淬炼,如今蓄势待发:2019年9月6-7日,大会将有近百位中美顶尖AI专家、知名企业代表以及千余名AI开发者齐聚北京,进行技术解读和产业论证。我们不空谈口号,只谈技术,诚挚邀请AI业内人士一起共铸人工智能新篇章!


发现网上很多Java面试题都没有答案,所以花了很长时间搜集整理出来了这套Java面试题大全,希望对大家有帮助哈~ 本套Java面试题大全,全的不能再全,哈哈~ 一、Java 基础 1. JDK 和 JRE 有什么区别? JDK:Java Development Kit 的简称,java 开发工具包,提供了 java 的开发环境和运行环境。 JRE:Java Runtime Environ...

定量遥感中文版 梁顺林著 范闻捷译


GIS程序设计教程 基于ArcGIS Engine的C#开发实例

张丰,杜震洪,刘仁义编著.GIS程序设计教程 基于ArcGIS Engine的C#开发实例.浙江大学出版社,2012.05


系列课程主要分为3大阶段:(1)首先掌握计算机视觉必备算法原理,结合Opencv进行学习与练手,通过实际视项目进行案例应用展示。(2)进军当下最火的深度学习进行视觉任务实战,掌握深度学习中必备算法原理与网络模型架构。(3)结合经典深度学习框架与实战项目进行实战,基于真实数据集展开业务分析与建模实战。整体风格通俗易懂,项目驱动学习与就业面试。 建议同学们按照下列顺序来进行学习:1.Python入门视频课程 2.Opencv计算机视觉实战(Python版) 3.深度学习框架-PyTorch实战/人工智能框架实战精讲:Keras项目 4.Python-深度学习-物体检测实战 5.后续实战课程按照自己喜好选择就可以




微信小程序番茄时钟视频教程,本课程将带着各位学员开发一个小程序初级实战类项目,针对只看过官方文档而又无从下手的开发者来说,可以作为一个较好的练手项目,对于有小程序开发经验的开发者而言,可以更好加深对小程序各类组件和API 的理解,为更深层次高难度的项目做铺垫。

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?




用verilog HDL语言编写的秒表




相关热词 c# 不能序列化继承类 c# char* 调用 c# 开发dll模板 c#添加控件到工具箱 c#控制台组合数 编程计算猴子吃桃问题c# c# wpf 背景透明 随机抽取号码软件c# c# 开发环境 c# 属性和字段