Slash.dgraph.io with pydgraph error status = StatusCode.UNAVAILABLE details = "Name resolution failure"

Hi All
I am attempting to get a python script on my local laptop connected to the Slash.dgraph.io server.

Any tips on getting started would be welcome.

Here is the error I am getting.

 File "/home/rnwolf/workspace/dgraph_playground/play_dgraph.py", line 28, in <module>
    res = txn.mutate(set_obj=mut)
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/pydgraph/txn.py", line 76, in mutate
    return self.do_request(req, timeout=timeout, metadata=metadata, credentials=credentials)
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/pydgraph/txn.py", line 125, in do_request
    self._common_except_mutate(query_error)
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/pydgraph/txn.py", line 222, in _common_except_mutate
    raise error
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/pydgraph/txn.py", line 103, in do_request
    credentials=credentials)
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/pydgraph/client_stub.py", line 57, in query
    credentials=credentials)
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/grpc/_channel.py", line 549, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/home/rnwolf/workspace/dgraph_playground/.venv/lib/python3.7/site-packages/grpc/_channel.py", line 466, in _end_unary_response_blocking
    raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "Name resolution failure"
        debug_error_string = "{"created":"@1599220596.426614600","description":"Failed to create subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":2267,"referenced_errors":[{"created":"@1599220596.426610900","description":"Name resolution failure","file":"src/core/ext/filters/client_channel/request_routing.cc","file_line":166,"grpc_status":14}]}"
>

on line 28 of the python file below : res = txn.mutate(set_obj=mut)

My requirements.txt file is

pydgraph
#grpcio-tools
grpcio==1.19.0

I am installing grpcio==1.19.0 based on this recommendation.

play_dgraph.py

import grpc
import sys
import json
from operator import itemgetter

import pydgraph


GRPC_HOST = "XXXXXXXXXXXX.eu-central-1.aws.cloud.dgraph.io/graphql"
GRPC_PORT = "443"
API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXX"

creds = grpc.ssl_channel_credentials()
call_credentials = grpc.metadata_call_credentials(lambda context, callback: callback((("Authorization", API_KEY),), None))
composite_credentials = grpc.composite_channel_credentials(creds, call_credentials)
client_stub = pydgraph.DgraphClientStub('{host}:{port}'.format(host=GRPC_HOST, port=GRPC_PORT), composite_credentials)
client = pydgraph.DgraphClient(client_stub)


mut = {
  "Person.name": "John Doe",
  "Person.age": "32",
  "Person.country": "US"
}

txn = client.txn()
try:
  res = txn.mutate(set_obj=mut)
  ppl = json.loads(res.json)
  print(ppl)
finally:
  txn.discard()



query = """
{
   queryPerson(func: type(Person))  {
     Person.name
     Person.age
     Person.country
  }
}"""
txn = client.txn()
try:
  res = txn.query(query)
  ppl = json.loads(res.json)
  print(ppl)
finally:
  txn.discard()


Hi. We are trying to make this a bit easier to do (opening helpers with each client), but your GRPC host should be

XXXXXXXXXXXX.grpc.eu-central-1.aws.cloud.dgraph.io (note the .grpc. there)

@gja thanks for your help.

I think I have a connection now. I am on to the next problem.

details = "Illegal metadata"

Back to the documents to continue my learning journey.

Sorry, we’ve been moving documentation sites and I think this change got rolled back. “Authorization” should be lower case “authorization”.

Thanks @gja I have established a connection.

And then I can get something back. Quite what it means I don’t know yet… But I will get there.

txn = client.txn()
result = txn.query("schema{}")
print(result)