kadina
kadina

Reputation: 5376

Trying to communicate with google dialogflow through python code is resulting error

We have written python code to communicate with google dialog flow. It is working fine on our local machines and in one of the build machines also it is working fine. Below is the code we write to communicate with dialogflow.

def diagflowInteraction(project_id, session_id, texts, language_code):
    """Returns the result of detect intent with texts as inputs.
    Using the same `session_id` between requests allows continuation
    of the conversation."""

    import dialogflow_v2 as dialogflow

    os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = '/data/DialogflowConfig.json'
    session_client = dialogflow.SessionsClient()

    session = session_client.session_path(project_id, session_id)
    print('Session path: {}\n'.format(session))
    text_input = dialogflow.types.TextInput(text=texts, language_code=language_code)
    query_input = dialogflow.types.QueryInput(text=text_input)
    print(query_input)

    response = session_client.detect_intent(session=session, query_input=query_input)

But one build machine which we are using for production is throwing below error.

google/api_core/timeout.py\", line 214, in func_with_timeout\n    return func(*args, **kwargs)\n  File \"/home/nodeappuser/.local/lib/python3.5/site-packages/google/api_core/grpc_helpers.py\", line 59, in error_remapped_callable\n    six.raise_from(exceptions.from_grpc_error(exc), exc)\n  File \"<string>\", line 2, in raise_from\ngoogle.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: '_RSAPrivateKey' object has no attribute 'sign'\n","timestamp":"2020-11-16T20:02:16.123Z","type":"err","process_id":0,"app_name":"ChatBotInterface"}

Not sure what is causing this issue on that machine. Couldn't find much on internet related to the issue. We found Error in python cryptography module: _RSAPrivateKey' object has no attribute 'sign for same type of issue which says having old cryptography library (1.7.1) is the issue and suggested to upgrade to 2.6.1. But all our machines has cryptography latest version 2.6.1 including the machine which is having the issue.

cryptography 1.2.3
pycrypto     2.6.1

We have production drop in 2 hours. Can any one please help me to fix this issue.

Upvotes: 0

Views: 264

Answers (1)

kadina
kadina

Reputation: 5376

PROD machine (which is not working) is using higher version "google-auth==1.23.0" ,grpcio==1.33.2, protobuf==3.14.0,pytz==2020.4

Other machines (which are working) are using lower version google-auth==1.22.1, grpcio==1.33.1,protobuf==3.13.0,pytz==2020.1

Updated the Prod machine also to older version to fix the issue even though not sure what is the issue.

Upvotes: 1

Related Questions