tmc / grpc-websocket-proxy

A proxy to transparently upgrade grpc-gateway streaming endpoints to use websockets
MIT License
553 stars 72 forks source link

fix: set write deadline before writing messages #31

Open alvarowolfx opened 2 years ago

alvarowolfx commented 2 years ago

I was having some weird behavior here when I set up ping/pong to keep the connection alive, where even with that, I was getting disconnected after some time.

Them I checked gorilla/websocket sample on how to keep the connection alive and noticed that their base samples resets the WriteDeadline on every write, this way keeping the connection alive. https://github.com/gorilla/websocket/blob/master/examples/chat/client.go#L91

So this commit added that behavior.