Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #69 #140

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion slackclient/_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from urllib import getproxies
from urlparse import urlparse

from slackclient._slackrequest import SlackRequest
from slackclient._channel import Channel
from slackclient._user import User
Expand Down Expand Up @@ -86,7 +89,16 @@ def parse_slack_login_data(self, login_data):

def connect_slack_websocket(self, ws_url):
try:
self.websocket = create_connection(ws_url)
options = {}
proxies = getproxies()
proxy = proxies.get('https', proxies.get('http'))
if proxy:
parsed_proxy = urlparse(proxy)
options['http_proxy_host'] = parsed_proxy.hostname
options['http_proxy_port'] = int(parsed_proxy.port) if parsed_proxy.port else 80
if parsed_proxy.username:
options['http_proxy_auth'] = (parsed_proxy.username, parsed_proxy.password)
self.websocket = create_connection(ws_url, **options)
self.websocket.sock.setblocking(0)
except:
raise SlackConnectionError
Expand Down