第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

發(fā)出 Get 請(qǐng)求后,Golang 程序返回 HTTP 狀態(tài)代碼 503 或掛起

發(fā)出 Get 請(qǐng)求后,Golang 程序返回 HTTP 狀態(tài)代碼 503 或掛起

Go
長(zhǎng)風(fēng)秋雁 2022-10-04 17:05:51
我嘗試通過(guò)發(fā)出獲取請(qǐng)求從 kibana 服務(wù)器獲取 csv 數(shù)據(jù)。在此服務(wù)器向我發(fā)送帶有數(shù)據(jù)的響應(yīng)后,我編寫csv文件并保存在某個(gè)地方。每次 csv 文件都有一行“掛起”。Kibana日志顯示狀態(tài)代碼503但是如果我把網(wǎng)址放在瀏覽器中,我可以得到帶有正確數(shù)據(jù)的csv文件。可能我需要等待更多來(lái)自基巴納的回應(yīng)。從我的角度來(lái)看,問(wèn)題就在下一個(gè):服務(wù)器可以向我發(fā)送帶有單行“待處理”的響應(yīng),這意味著它需要更多時(shí)間來(lái)準(zhǔn)備正確的響應(yīng)。我試圖增加客戶時(shí)間,但它不起作用client := http.Client{    Timeout: 10 * time.Second,}接下來(lái)是帶有g(shù)o例程和通道/等待組的想法:他們強(qiáng)制Get請(qǐng)求等待獲取正確的數(shù)據(jù),而不是“待定”和503狀態(tài)代碼import (    "encoding/json"    "errors"    "fmt"    "io/ioutil"    "log"    "net/http"    "sync")type KibanaReportResponse struct {    Path string `json:"path"`}var urlKibanaBase = "http://localhost:5601"var urlKibanaPost = urlKibanaBase + "/api/reporting/generate/csv_searchsource?"var urlParameters = "jobParams=%28browserTimezone%3AEurope%2FBerlin%2Ccolumns%3A%21%28%29%2CobjectType%3Asearch%2CsearchSource%3A%28fields%3A%21%28%28field%3A%27%2A%27%2Cinclude_unmapped%3Atrue%29%29%2Cindex%3Aec074c00-1f62-11ec-8056-8d208a1f6e77%2Cparent%3A%28filter%3A%21%28%29%2Cindex%3Aec074c00-1f62-11ec-8056-8d208a1f6e77%2Cquery%3A%28language%3Akuery%2Cquery%3A%27%27%29%29%2Csort%3A%21%28%28_score%3Adesc%29%29%2CtrackTotalHits%3A%21t%2Cversion%3A%21t%29%2Ctitle%3A%27Discover%20search%20%5B2021-09-27T09%3A19%3A44.977%2B02%3A00%5D%27%29"var urlWithParam = urlKibanaPost + urlParametersfunc main() {    var wg sync.WaitGroup    wg.Add(1)    pathCsvFile := getCsvPathFromKibana(urlWithParam)    go getCsvFile(urlKibanaBase, pathCsvFile, &wg)    defer wg.Wait()}func getCsvPathFromKibana(urlKib string) string {    resKibana := KibanaReportResponse{}    client := &http.Client{}    if req, err := http.NewRequest("POST", urlKib, nil); err != nil {        log.Println("Given a method, URL, andoptional body are wrong", err)    }
查看完整描述

1 回答

?
吃雞游戲

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

Kibana 服務(wù)器需要一些時(shí)間來(lái)準(zhǔn)備響應(yīng)。我添加了一些代碼,用于向通道發(fā)出信號(hào),以等待一段時(shí)間,并在等待向客戶端重復(fù)請(qǐng)求后再等待

if res.StatusCode != 200 {
                    time.Sleep(30 * time.Second)
                }


查看完整回答
反對(duì) 回復(fù) 2022-10-04
  • 1 回答
  • 0 關(guān)注
  • 661 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)