I have an GRPC server which provides an function and returns a stream. I want to save the stream onto a map[string]grpc.Stream
- this works so far.
My problem is that the stream gets closed after the function that returns the stream finishes its logic.
This is, what I have so far:
func (s *server) CheckConnection(initMessage *LighterGRPC.InitMessage, stream LighterGRPC.Lighter_CheckConnectionServer) error {
//Do something magic
streams[initMessage.DeviceID] = stream
error := stream.Send(&LighterGRPC.ColorMessage{DATA})
if error {
log.Println(error)
}
//Tried
//for { }
return error
}
I already tried to let the function never return anything with an for {}
before the return (as commented in the code above), but that didn't helped and I don't think, that this could be the solution.
Is there a way to leave the stream open so I can send data later in runtime over it to the client?