# java.net.ConnectException: Operation timed out when posting messages to slack incoming web hook

**URL:** https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [October 7, 2016, 5:25am UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455 "2016-10-07T05:25:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![pvishwamitrula](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pvishwamitrula](https://discuss.elastic.co/u/pvishwamitrula)
#### Post date: [October 7, 2016, 5:25am UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/1 "2016-10-07T05:25:43Z")

</div>

1. I have created new incoming web hook for my channel.
2. Used incoming webhook in elasticsearch.yml file to send slack messages.

watcher.actions.slack.service:  
account:  
monitoring:  
url: [https://hooks.slack.com/services/xxx/xxx/xxxx](https://hooks.slack.com/services/xxx/xxx/xxxx)  
message\_defaults:  
from: Watcher

**Created new watch to alert me when cluster status is yellow.**

PUT /\_watcher/watch/cluster\_health\_yellow\_slack\_watch  
{  
"trigger": {  
"schedule": {  
"interval": "30s"  
}  
},  
"input" : {  
"http" : {  
"request" : {  
"host" : "localhost",  
"port" : 9200,  
"path" : "/\_cluster/health"  
}  
}  
},

"condition" : {  
"compare" : {  
"ctx.payload.status" : { "eq" : "yellow" }  
}  
},  
"actions": {  
"send\_trigger": {  
"webhook": {  
"method": "POST",  
"scheme": "https",  
"port": 443,  
"host": "[hooks.slack.com](http://hooks.slack.com)",  
"path": "/services/xxx/xxx/xxx",  
"body": "{ "text": "Cluster status is Yellow - 06 OCT 11:45 "}",  
"headers": {  
"Content-type": "application/json"  
}  
}  
}  
}  
}

Below is the exception message I am seeing:

[2016-10-07 00:11:14,395][ERROR][watcher.actions.webhook] [Trick Shot] failed to execute action [cluster\_health\_yellow\_slack\_watch/send\_trigger]  
java.net.ConnectException: Operation timed out  
at java.net.PlainSocketImpl.socketConnect(Native Method)  
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)  
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)  
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)  
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)  
at java.net.Socket.connect(Socket.java:589)  
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)  
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)  
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)  
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)  
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)  
at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:275)  
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)  
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)  
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1147)  
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:998)  
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)  
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1282)  
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1257)  
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)  
at org.elasticsearch.watcher.support.http.HttpClient.doExecute(HttpClient.java:192)  
at org.elasticsearch.watcher.support.http.HttpClient.execute(HttpClient.java:125)  
at org.elasticsearch.watcher.actions.webhook.ExecutableWebhookAction.execute(ExecutableWebhookAction.java:57)  
at org.elasticsearch.watcher.actions.ActionWrapper.execute(ActionWrapper.java:106)  
at org.elasticsearch.watcher.execution.ExecutionService.executeInner(ExecutionService.java:388)  
at org.elasticsearch.watcher.execution.ExecutionService.execute(ExecutionService.java:273)  
at org.elasticsearch.watcher.execution.ExecutionService$WatchExecutionTask.run(ExecutionService.java:438)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)  
at java.lang.Thread.run(Thread.java:745)

**NOTE: This issue is only when I am using my company network, Works fine on my home Wifi Connection.**

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [October 7, 2016, 2:18pm UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/2 "2016-10-07T14:18:41Z")

</div>

Hey,

you already parttially answered your issue with your last sentence. The occuring timeout mentioned in the exception is very likely, because in your corporate network there are some filters in place, which dont allow the system, which watcher and elasticsearch is running on, to communicate with the internet.

Please sync with your system administrators what can be done about that. You might already get away by using a company proxy, but that depends on your company setup of course.

--Alex

---

<div class="post-metadata">

### Author: ![pvishwamitrula](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pvishwamitrula](https://discuss.elastic.co/u/pvishwamitrula)
#### Post date: [October 7, 2016, 3:45pm UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/3 "2016-10-07T15:45:01Z")

</div>

Thank you Alex for the response.

Can we setup proxy in elasticsearch.yml to overcome this problem? I am using below properties  
watcher.https.proxy.host: [https://proxy.xxx.com](https://proxy.xxx.com)  
watcher.https.proxy.port: xxxx  
watcher.http.proxy.host: [http://proxy.xxx.com](http://proxy.xxx.com)  
watcher.http.proxy.port: xxxx

GET \_nodes/settings is showing

{  
"cluster\_name": "elasticsearch",  
"nodes": {  
"JhbdQdjAR6O7dIPkE\_eIPg": {  
"name": "Soldier X",  
"transport\_address": "127.0.0.1:9300",  
"host": "127.0.0.1",  
"ip": "127.0.0.1",  
"version": "2.3.4",  
"build": "e455fd0",  
"http\_address": "127.0.0.1:9200",  
"settings": {  
"watcher": {  
"actions": {  
"slack": {  
"service": {  
"account": {  
"monitoring": {  
"message\_defaults": {  
"from": "Watcher"  
},  
"url": "[https://hooks.slack.com/services/xxx/xxx/xxx](https://hooks.slack.com/services/xxx/xxx/xxx)"  
}  
}  
}  
}  
},  
"http": {  
"proxy": {  
"host": "[http://proxy.xxx.com](http://proxy.xxx.com)",  
"port": "xxxx"  
}  
},  
"https": {  
"proxy": {  
"host": "[https://proxy.xxx.com](https://proxy.xxx.com)",  
"port": "xxxx"  
}  
}  
},  
"cluster": {  
"name": "elasticsearch"  
},  
"path": {  
"logs": "/Users/xxxxxx/Softwares/elasticsearch-2.3.4/logs",  
"home": "/Users/xxxxx/Softwares/elasticsearch-2.3.4"  
},  
"shield": {  
"enabled": "false"  
},  
"name": "Soldier X",  
"client": {  
"type": "node"  
},  
"config": {  
"ignore\_system\_properties": "true"  
},  
"threadpool": {  
"watcher": {  
"queue\_size": "1000",  
"size": "40",  
"type": "fixed"  
}  
},  
"script": {  
"inline": "true",  
"indexed": "true"  
}  
}  
}  
}  
}

I am doing it right?

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [October 10, 2016, 8:46am UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/4 "2016-10-10T08:46:17Z")

</div>

Hey,

you only need `watcher.http.proxy.*` settings, see [the docs](https://www.elastic.co/guide/en/watcher/2.4/watcher-settings.html#watcher-settings).

Make sure you update that setting on all your nodes and restart them.

--Alex

---

<div class="post-metadata">

### Author: ![pvishwamitrula](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@pvishwamitrula](https://discuss.elastic.co/u/pvishwamitrula)
#### Post date: [October 18, 2016, 7:55pm UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/5 "2016-10-18T19:55:48Z")

</div>

Hey Alex,

How can I pass credentials for the proxy?

These two setting will work?  
watcher.http.proxy.username: xxxx  
watcher.http.proxy.password: xxxx

Please let me know

Prashanth

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [October 19, 2016, 9:03am UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/6 "2016-10-19T09:03:10Z")

</div>

Hey,

passing credentials for the proxy is not supported at the moment, you can only pass credentials for the HTTP request as part of the watch.

We did not have a lot of requests regarding that, but it should not be too hard to implement I guess.

--Alex

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 1:42pm UTC](https://discuss.elastic.co/t/java-net-connectexception-operation-timed-out-when-posting-messages-to-slack-incoming-web-hook/62455/7 "2017-07-06T13:42:31Z")

</div>


