0

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.

kadina
  • 5,042
  • 4
  • 42
  • 83
  • Did you manage to solve this issue? My understanding of the error `503 Getting metadata from plugin failed` you observe is that it is often related to a credentials issue. [Test](https://cloud.google.com/dialogflow/es/docs/quick/setup#auth-test) the credentials and I would recommend adding them in the [client](https://googleapis.dev/nodejs/dialogflow/latest/v2beta1.SessionsClient.html) itself instead of as an environment variable as it is a better practice. For that you may follow [this](https://stackoverflow.com/a/56099099/12852090) example for Vision api and adapt it to Dialogflow api. – aemon4 Nov 19 '20 at 10:25
  • Moreover, look for differences between the machines, like different versions of the cloud sdk, the dialogflow client library,... and share if both machines are in the same or different projects. – aemon4 Nov 19 '20 at 10:26
  • Thanks @aemon4. In fact some of the dialog flow versions are different on the Production machine. Forgot to post the answer. – kadina Nov 24 '20 at 04:03

1 Answers1

1

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.

kadina
  • 5,042
  • 4
  • 42
  • 83