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

python shows error RequestsFutureAdapterConnectionError #200

Open
studyquant opened this issue Aug 16, 2018 · 7 comments
Open

python shows error RequestsFutureAdapterConnectionError #200

studyquant opened this issue Aug 16, 2018 · 7 comments

Comments

@studyquant
Copy link

python 3.5, I am using

import json
import bitmex
client = bitmex.bitmex(test=True, api_key=api_key, api_secret=api_secret)

unable to connect

@jasonlll
Copy link

me too

@dh12306
Copy link

dh12306 commented Sep 9, 2018

also

@mmmaaaggg
Copy link

import bitmex
client = bitmex.bitmex() # when invoking this line exception will be threw as below

Traceback (most recent call last):
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connection.py", line 171, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\util\connection.py", line 79, in create_connection
    raise err
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\util\connection.py", line 69, in create_connection
    sock.connect(sa)
TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应连接尝试失败During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connectionpool.py", line 849, in _validate_conn
    conn.connect()
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connection.py", line 314, in connect
    conn = self._new_conn()
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connection.py", line 180, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x00000170ACFDD7B8>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应连接尝试失败During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "D:\WSPych\RefUtils\venv\lib\site-packages\requests\adapters.py", line 445, in send
    timeout=timeout
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "D:\WSPych\RefUtils\venv\lib\site-packages\urllib3\util\retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='testnet.bitmex.com', port=443): Max retries exceeded with url: /api/explorer/swagger.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000170ACFDD7B8>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 96, in wrapper
    return func(self, *args, **kwargs)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 227, in _get_incoming_response
    inner_response = self.future.result(timeout=timeout)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\requests_client.py", line 296, in result
    timeout=self.build_timeout(timeout),
  File "D:\WSPych\RefUtils\venv\lib\site-packages\requests\sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\requests\adapters.py", line 513, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='testnet.bitmex.com', port=443): Max retries exceeded with url: /api/explorer/swagger.json (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x00000170ACFDD7B8>: Failed to establish a new connection: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。',))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bitmex.py", line 38, in bitmex
    return SwaggerClient.from_url(spec_uri, config=config)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\client.py", line 96, in from_url
    spec_dict = loader.load_spec(spec_url)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\swagger_model.py", line 100, in load_spec
    self.request_headers,
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 212, in result
    incoming_response = self._get_incoming_response(timeout)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 100, in wrapper
    self.future._raise_connection_error(exception)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 74, in _raise_connection_error
    self._raise_error(BravadoConnectionError, 'ConnectionError', exception)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 67, in _raise_error
    sys.exc_info()[2],
  File "D:\WSPych\RefUtils\venv\lib\site-packages\six.py", line 692, in reraise
    raise value.with_traceback(tb)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 96, in wrapper
    return func(self, *args, **kwargs)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\http_future.py", line 227, in _get_incoming_response
    inner_response = self.future.result(timeout=timeout)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\bravado\requests_client.py", line 296, in result
    timeout=self.build_timeout(timeout),
  File "D:\WSPych\RefUtils\venv\lib\site-packages\requests\sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "D:\WSPych\RefUtils\venv\lib\site-packages\requests\adapters.py", line 513, in send
    raise ConnectionError(e, request=request)
bravado.http_future.RequestsFutureAdapterConnectionError

@shawan12
Copy link

me too

@shawan12
Copy link

终于解决了,首先你要设置一个代理(美国的IP可以正常访问,香港的Ip访问依然有问题)然后修改bitmex的源码,设置代理,参考文章https://github.com/Yelp/bravado/issues/361,这样走代理就可以正常访问了

@cqtenq
Copy link

cqtenq commented Oct 19, 2018

这样改了还是不行:
request_client = RequestsClient()
request_client.authenticator = APIKeyAuthenticator(host, api_key, api_secret)

    return SwaggerClient.from_url(spec_uri, config=config, http_client=request_client, proxy = proxies)

@mmmaaaggg
Copy link

这样改了还是不行:
request_client = RequestsClient()
request_client.authenticator = APIKeyAuthenticator(host, api_key, api_secret)

    return SwaggerClient.from_url(spec_uri, config=config, http_client=request_client, proxy = proxies)

后来发现了,只是翻墙都不行,找了一台google服务期在上面跑的可以跑通。
在自己的机器上,翻了墙一样连不上

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants