google / generative-ai-docs

Documentation for Google's Gen AI site - including the Gemini API and Gemma
https://ai.google.dev
Apache License 2.0
1.68k stars 604 forks source link

A few days ago, there was no problem calling the API, but today there has been no successful access and an access exception has occurred #314

Open Jianhong-user opened 7 months ago

Jianhong-user commented 7 months ago

Description of the bug:

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "D: \ Python environment \ Project \ Gemini API \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ retry \ retry_unary. py", line 144, in retry_target

Result=target()

^^^^^^^^

File "D: \ Python_environment \ Project \ Gemini-Api \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ time out. py", line 120, in func_with_time out

Return fun ( args, * kwargs)

^^^^^^^^^^^^^^^^^^^^^

File "D: \ Python environment \ Project \ Gemini API \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ grpc_helpers. py", line 78, in error remopped_callable

Raise exceptions. from grpc_error (exc) from exc

Google. api_core. exceptions ServiceUnavailable: 503 failed to connect to all addresses; Last error: UNKNOWN: ipv4:142.251.42.234:443: TCP handshake shutdown

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "D: \ Python environment \ Project \ Gemini-Api \ pythonProject \ Refactoring \ 1. py", line 18, in

"I plan to go to Japan and have always wanted to see cherry blossoms there."

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D: \ Python environment \ Project \ Gemini-Api \ pythonProject . venv \ Lib \ site packages \ Google \ generateai \ generative_models. py", line 426, in send_message

Response=self. model. generate.content(

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D: \ Python environment \ Project \ Gemini-Api \ pythonProject . venv \ Lib \ site packages \ Google \ generateai \ generative_models. py", line 232, in generate.content

Response=self_ Client.generate_content(

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D: \ Python environment \ Project \ Gemini API \ pythonProject . venv \ Lib \ site packages \ Google \ ai \ generativelanguage_v1beta \ services \ generative_service \ client. py", line 566, in generate.content

Response=rpc(

^^^^

File "D: \ Python environment \ Project \ Gemini-Api \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ gapic_v1 \ method. py", line 131, in call

Return wrapped_fun ( args, * kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "D: \ Python environment \ Project \ Gemini API \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ retry \ retry_unary. py", line 293, in retry_wrapped_fun

Return retry_target(

^^^^^^^^^^^^^

File "D: \ Python environment \ Project \ Gemini API \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ retry \ retry_unary. py", line 153, in retry_target

_Retryerror helper(

File "D: \ Python environment \ Project \ Gemini API \ pythonProject . venv \ Lib \ site packages \ Google \ api_core \ retry \ retry_base. py", line 221, in _retry_error_helper

Raise final_exc from source_exc

Google. api_core. exceptions RetryError: timeout of 60.0s exceeded, last exception: 503 failed to connect to all addresses

Actual vs expected behavior:

No response

Any other information you'd like to share?

No response

jhaayush2004 commented 1 month ago

These Steps may Resolve the Issue:

  1. Verify Network Configuration:

    • Ensure your environment can connect to the internet without restrictions like firewalls or proxy issues that might block the service.
    • Use network tools like ping or traceroute to check if the address 142.251.42.234:443 (the IP from the error) is reachable from your environment.
  2. Retry with Exponential Backoff:

    • Use an exponential backoff retry strategy to handle temporary service unavailability more gracefully. The retry delay should increase with each attempt to give the server more time to recover.
  3. Increase Timeout Settings:

    • The timeout error indicates that the connection attempt was limited to 60 seconds. Try increasing the timeout in your API calls to allow more time for the service to respond.
  4. Check API Quotas and Limits