我有使用gRPC的客户端。我的问题是,由于无法删除的dns中的错误,它无法编译。如果我对创建部分发表评论,那么它可以工作(但我必须使用创建部分):
# example_consumer.py
import pika, os, time
import grpc
import garden_pb2_grpc
import garden_pb2
# Access the CLODUAMQP_URL environment variable and parse it (fallback to localhost)
url = os.environ.get('CLOUDAMQP_URL', 'amqp://lay5672')
params = pika.URLParameters(url)
connection = pika.BlockingConnection(params)
channel = connection.channel() # start a channel
channel.queue_declare(queue='garden') # Declare a queue
grpcChannel = grpc.insecure_channel('https://') # connection
stub = garden_pb2_grpc.GardenServiceStub(grpcChannel)
my_garden = garden_pb2.Garden(
id="5d0a61f86e95521de096efb3",
position=garden_pb2.Garden.Position(lat=1, lng=2),
size=garden_pb2.Garden.Size(height=10, width=20),
garden=[],
userID="5d0a61f86e95521de096efb3"
)
createRequest = garden_pb2.CreateRequest(
garden=my_garden
)
def garden_process_function(msg):
print("Received " + str(msg))
print("This function can do something")
time.sleep(1) # delays for 5 seconds
feature = stub.Create(createRequest) # je dois appeler avec un objet create request
return;
# create a function which is called on incoming messages
def callback(ch, method, properties, body):
garden_process_function(body)
class Server(object):
@staticmethod
def receiveMsg():
# set up subscription on the queue
channel.basic_consume('garden',
callback,
auto_ack=True)
# start consuming (blocks)
channel.start_consuming()
connection.close()
class App(object):
@staticmethod
def run():
print('Running...')
if __name__ == '__main__':
App.run()
Server.receiveMsg()
但是我得到了这个错误:
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "DNS resolution failed"
debug_error_string = "{"created":"@1570759414.997000000","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3876,"referenced_errors":[{"created":"@1570759414.997000000","description":"Resolver transient failure","file":"src/core/ext/filters/client_channel/resolving_lb_policy.cc","file_line":263,"referenced_errors":[{"created":"@1570759414.997000000","description":"DNS resolution failed","file":"src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc","file_line":189,"grpc_status":14,"referenced_errors":[{"created":"@1570759414.997000000","description":"OS Error","file":"src/core/lib/iomgr/resolve_address_windows.cc","file_line":96,"os_error":"The specified class was not found.\r\n","syscall":"getaddrinfo","wsa_error":10109}]}]}]}
我做错了什么?我根本不明白这个错误。我在窗户下