boto3 ConnectionClosedError python - PullRequest
1 голос
/ 27 мая 2020

Я пытаюсь развернуть Rest Api с Chalice. Когда я развертываю чашу.

Код работал с локальной чашей. Но это не удается при развертывании.

Я получаю следующую ошибку:

Creating deployment package.
Updating policy for IAM role: learnChalice-dev
Updating lambda function: learnChalice-dev
Traceback (most recent call last):
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/awsrequest.py", line 92, in _send_request
    method, url, body, headers, *args, **kwargs)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/awsrequest.py", line 119, in _send_output
    self.send(msg)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/awsrequest.py", line 203, in send
    return super(AWSConnection, self).send(str)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 987, in send
    self.sock.sendall(data)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/ssl.py", line 1034, in sendall
    v = self.send(byte_view[count:])
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/ssl.py", line 1003, in send
    return self._sslobj.write(data)
socket.timeout: The write operation timed out

Во время обработки вышеуказанного исключения произошло другое исключение:

Traceback (most recent call last):
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 263, in send
    chunked=self._chunked(request.headers),
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/util/retry.py", line 344, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/dragon/.local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/awsrequest.py", line 92, in _send_request
    method, url, body, headers, *args, **kwargs)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/awsrequest.py", line 119, in _send_output
    self.send(msg)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/awsrequest.py", line 203, in send
    return super(AWSConnection, self).send(str)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/http/client.py", line 987, in send
    self.sock.sendall(data)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/ssl.py", line 1034, in sendall
    v = self.send(byte_view[count:])
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/ssl.py", line 1003, in send
    return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', timeout('The write operation timed out'))

Во время обработки вышеупомянутое исключение, произошло другое исключение:

Traceback (most recent call last):
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/cli/__init__.py", line 599, in main
    return cli(obj={})
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)

File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/click/core.py ", строка 610, при вызове обратного вызова возврата (* args, ** kwargs) Файл" /home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/click/decorators.py ", строка 21, в new_func return f (get_current_context (), * args, ** kwargs) File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/cli/ init .py ", строка 206, в файле deployed_values ​​= d.deploy (config, chalice_stage_name = stage)" /home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/ chalice / deploy / deployer.py ", строка 353, при развертывании возвращает self._deploy (config, chalice_stage_name) File" /home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/ развернуть / депло yer.py ", строка 366, в файле _deploy self._executor.execute (план)" /home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/deploy/executor.py ", строка 44, в execute self._default_handler) (инструкция) Файл" /home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/deploy/executor.py ", строка 56 , в _do_apicall result = method (** final_kwargs) File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/awsclient.py", строка 273, в update_function zip_contents = zip_contents)

  File "/home/dragon/anaconda3/envs/my_env/lib/python3.7/site-packages/chalice/awsclient.py", line 294, in _update_function_code
    FunctionName=function_name, ZipFile=zip_contents)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/client.py", line 316, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/client.py", line 613, in _make_api_call
    operation_model, request_dict, request_context)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/client.py", line 632, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
    success_response, exception):
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 231, in _needs_retry
    caught_exception=caught_exception, request_dict=request_dict)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
    if self._checker(attempts, response, caught_exception):
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
    caught_exception)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
    return self._checker(attempt_number, response, caught_exception)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
    caught_exception)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
    attempt_number, caught_exception)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
    raise caught_exception
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
    http_response = self._send(request)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 244, in _send
    return self.http_session.send(request)
  File "/home/dragon/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 294, in send
    endpoint_url=request.url
botocore.exceptions.ConnectionClosedError: Connection was closed before we received a valid response from endpoint URL: "https://lambda.ap-south-1.amazonaws.com/2015-03-31/functions/learnChalice-dev/code".

Большое спасибо за помощь.

1 Ответ

1 голос
/ 27 мая 2020

Исходя из комментариев, решением было увеличить тайм-аут по умолчанию:

chalice deploy --connection-timeout 300
...