gRPC-Swift sometimes has GRPCStatus - Cancel

473 views Asked by At

I'm new with gRPC and use pod gRPC-Swift version 1.0.0-alpha.21. Sometimes I have an error in my response - error.localizedDescription is "The operation couldn’t be completed. (GRPC.GRPCStatus error 1.)", I've noticed that errorCode = 1 means "The operation was cancelled, typically by the caller.", but I don't have any ideas why it happens. Here is my code:

let tls = ClientConnection.Configuration.TLS.init(certificateChain: [], privateKey: .none, trustRoots: .default, certificateVerification: .fullVerification, hostnameOverride: nil)
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let host = "myhost"
let port = 443
let configuration = ClientConnection.Configuration(target: .hostAndPort(host, port),
                                                   eventLoopGroup: group,
                                                   tls: tls)
let clientConnection = ClientConnection(configuration: configuration)
let installService = Installapi_IngesterClient(channel: clientConnection)
let deviceRequest = Installapi_DeviceRequest()
let call = installService.setDevice(deviceRequest)
call.response.whenComplete { result in
  switch result {
    case .success:
      // success
    case .failure(let error):
      print(error.localizedDescription)
  }
}

I would appreciate any ideas.

0

There are 0 answers