Hi,
am trying to communicate with grpc server with golang. After logging I include in metadata jwt token to authenticate to the server seems correctly but the line below got always with an error 13
app, err := api.NewApplicationServiceClient(grpcConn).Get(ctx, &api.GetApplicationRequest{
Id: 2,
})
Error msg:
rpc error: code = Internal desc = stream terminated by RST_STREAM with error code: PROTOCOL_ERROR
Also, in server side I get similar message:
http2: server connection error from 192.168.1.103:54387: connection error: PROTOCOL_ERROR
Do you know why login works fine while NewApllicationServiceClient not?
@brocaar have you already seen something similar?
brocaar
September 12, 2018, 9:52am
#3
I have not had this error myself yet. Given that you get a protocol error, are you sure your are not mixing TLS and non-TLS in your client and server?
Thanks for reply.
Actually, I saw in your auth.go server side that only “authorization” metadata is expected while I was trying from client with
"Grpc-Metadata-Authorization: Bearer" : JWT
Now it works with following metadata.
"Authorization" : JWT
julien
September 15, 2018, 11:18am
#5
Hello @ale16384 ,
I’m really interested by an example indeed as you can see from this link (https://forum.loraserver.io/t/grpc-api-and-go/2209 ), I’m trying to use grpc server with golang.
Thank you for your help.
Hello,
Do you need an example to do what?
If you need to communicate with gRPC server with your client written in golang I suggest you to think about what you want to do with your client first then you can use the api list in the following page brocaar provided.
julien
September 16, 2018, 2:27pm
#7
Hello, thank for your answer,
In fact to start I want to use client “Go func” related to DeviceQueueItem in order to handle the data.
But the starting point is to connect to grpc server, I’m looking for any example of how to connect to the grpc server from main.go script.
I found this example but I’m looking for another to compare them.
Do you read my link in previous reply, because I 'm not sure of my understanding about grpc method and how to use it ?
Thank you so much for your help.
gRPC server can be reached by using grpc.Dial method. Yes…
In my configuration I couldn’t use following option because external server api uses TLS authentication.
grpc.WithInsecure()
If you cannot connect to the server you should see this from lora-app-server log. Use following command to check it.
journalctl -u lora-app-server.service -n 100
I use to connect from client remotely using server TLS certificate file “http.pem”
func GRPCConn() *grpc.ClientConn {
creds, err := credentials.NewClientTLSFromFile("http.pem", "localhost")
asConn, err := grpc.Dial("192.168.1.110:8080", grpc.WithTransportCredentials(creds), grpc.WithTimeout(time.Millisecond*10000))
if err != nil {
log.Fatal(err)
}
return asConn
}
I hope this can help.
1 Like