You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/02/23 14:55:02 UTC

[GitHub] [skywalking] haoyann commented on issue #6424: the webhook has error:Timeout waiting for connection from pool

haoyann commented on issue #6424:
URL: https://github.com/apache/skywalking/issues/6424#issuecomment-784259051


   `httpResponse` should be closed.
   ```
       private void sendAlarmMessage(CloseableHttpClient httpClient, String url, String requestBody) {
           try {
               HttpPost post = new HttpPost(url);
               post.setConfig(requestConfig);
               post.setHeader(HttpHeaders.ACCEPT, HttpHeaderValues.APPLICATION_JSON.toString());
               post.setHeader(HttpHeaders.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON.toString());
               StringEntity entity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
               post.setEntity(entity);
               CloseableHttpResponse httpResponse = httpClient.execute(post);
               StatusLine statusLine = httpResponse.getStatusLine();
               if (statusLine != null && statusLine.getStatusCode() != HttpStatus.SC_OK) {
                   log.error("send dingtalk alarm to {} failure. Response code: {}, Response content: {}", url, statusLine.getStatusCode(),
                           EntityUtils.toString(httpResponse.getEntity()));
               }
           } catch (Throwable e) {
               log.error("send dingtalk alarm to {} failure.", url, e);
           }
       }
   ```
   https://hc.apache.org/httpcomponents-client-4.5.x/quickstart.html


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org