grpc-swift icon indicating copy to clipboard operation
grpc-swift copied to clipboard

Getting error unknown (2) when making UnaryCall call.

Open araisuki opened this issue 1 year ago • 4 comments

What are you trying to achieve?

Getting error unknown (2) when making UnaryCall call.

What have you tried so far?

The request doesn't seems to be reaching our server.

araisuki avatar Sep 13 '24 13:09 araisuki

Could you provide more information about what you're doing, how you're trying to do it and where you're seeing the error?

There isn't anything actionable we can do with the information you have provided.

glbrntt avatar Sep 13 '24 13:09 glbrntt

@glbrntt This how my code is

let clientConnectionHost = SukiAmbientCoreManager.shared.environment.getSocketConntectionHost()
let clientConnectionPort = 443
micChannel = ClientConnection.usingPlatformAppropriateTLS(for: group)
            .connect(host: clientConnectionHost, port: clientConnectionPort)
sdpServiceClient = Suki_Pb_Sdp_SDPServiceNIOClient.init(channel: micChannel)
        sdpServiceClient.defaultCallOptions.customMetadata.add(name: "ambient_session_id", value: recordingId)
        sdpServiceClient.defaultCallOptions.customMetadata.add(name:"sdp_suki_token",
                                                               value: TokenManager.shared.getToken() ?? "")
        micChannel.connectivity.delegate = delegate

Below how I am making an GRPC call

var request = Suki_Pb_Sdp_AuthenticationRequest()
        request.partnerID = partnerId
        request.partnerToken = partnerToken
        let task = self.sdpServiceClient.authenticate(request)
        task.response.whenComplete { result in
            switch result {
            case .success(let response):
                completionHandler(.success(response))
                break
            case .failure(let error):
                print(error)
                completionHandler(.failure(error))
                break
            }
        }

Here how authenticate UnaryRPC looks like. This is compiler generated code.

internal func authenticate(
    _ request: Suki_Pb_Sdp_AuthenticationRequest,
    callOptions: CallOptions? = nil
  ) -> UnaryCall<Suki_Pb_Sdp_AuthenticationRequest, Suki_Pb_Sdp_AuthenticationResponse> {
    return self.makeUnaryCall(
      path: Suki_Pb_Sdp_SDPServiceClientMetadata.Methods.authenticate.path,
      request: request,
      callOptions: callOptions ?? self.defaultCallOptions,
      interceptors: self.interceptors?.makeAuthenticateInterceptors() ?? []
    )
  }

araisuki avatar Sep 13 '24 14:09 araisuki

And also it happens only for my client using the app, If I use app with the same account it works fine. I suspect is it something to do with the network? But instead of unknown(2) error some valid error might be useful to understand

araisuki avatar Sep 13 '24 14:09 araisuki

unknown is a valid gRPC status code. It's possible the server returned an error with this status to the client.

Is there a message with the error?

glbrntt avatar Sep 13 '24 15:09 glbrntt