亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

504 網關超時問題在彈簧啟動休息調用重記錄(超過 80K)

504 網關超時問題在彈簧啟動休息調用重記錄(超過 80K)

青春有我 2022-09-14 16:59:18
我得到504網關超時問題春季啟動休息調用使用HTTP GET調用重記錄(超過80K),我正在調用其他服務使用 RestTemplate 對象 resClient 獲取數據,代碼如下:public ResponseEntity<String> getData(String endPointUrl, Map<String, Object> parameterMap, String smToken) throws Exception {        HttpHeaders headers = new HttpHeaders();        headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));        headers.add("Cookie", smToken);        //headers.setContentType(MediaType.APPLICATION_JSON_UTF8);        HttpEntity<Map<String, Object>> entity = new HttpEntity<Map<String, Object>>(parameterMap, headers);        ResponseEntity<String> responseEntity = null;        try {            SSLUtil.turnOffSslChecking();            LOGGER.info("Start call to end point : " +endPointUrl+ " at :"+ (new Date().toString()) );            //resClient.getMessageConverters()            //.add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));            responseEntity = resClient.exchange(endPointUrl, HttpMethod.POST, entity,String.class);            LOGGER.info("End of call to end point : " +endPointUrl+ " at :"+ (new Date().toString()) );            LOGGER.debug("Response from end point: " + responseEntity);        } catch (Exception e) {            LOGGER.error("Exception while making a http call to " + endPointUrl,e);            throw e;        }        return responseEntity;    }在調試時,我看到來自其他服務調用的響應它需要超過4分鐘的時間,但不是等到那個時候得到它使用的響應,而是在3分鐘后才出來。我們如何等待來自其他服務呼叫的響應?我試圖使用屬性服務器.連接超時=300000在應用程序屬性中將超時時間增加到5分鐘來解決此問題,但我得到的響應為空。我不確定這是否是正確的方法。請在這個問題上幫助我。
查看完整描述

3 回答

?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

504網關超時問題通常由代理服務器引發,這意味著服務器正在關閉連接。如果客戶端關閉連接,您將收到連接超時錯誤。


查看完整回答
反對 回復 2022-09-14
?
胡說叔叔

TA貢獻1804條經驗 獲得超8個贊

server.connection-timeout= #


連接器在關閉連接之前等待另一個 HTTP 請求的時間。如果未設置,則使用連接器的特定于容器的默認值。


Use a value of -1 to indicate no (that is, an infinite) timeout. (might be bad fix)

或 嘗試從應用程序設置它


@SpringBootApplication

public class Application {

    public static void main(String[] args) throws Exception {

        System.setProperty("server.port","8080"));

        System.setProperty("server.connection-timeout","300000");

        System.setProperty("server.tomcat.max-threads","yourValue"); //in-case if you want to chaneg number of thredas 

        SpringApplication.run(Application.class, args);

    }

}

另外,請參閱


查看完整回答
反對 回復 2022-09-14
?
子衿沉夜

TA貢獻1828條經驗 獲得超3個贊

試試這個

@Bean
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) 
    {        return restTemplateBuilder
           .setConnectTimeout(...)
           .setReadTimeout(...)
           .build();
    }


查看完整回答
反對 回復 2022-09-14
  • 3 回答
  • 0 關注
  • 139 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號