websocket transport could be killed while javascript is asleep.
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 802
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 5
Description
Hi thanks for the great work.
I encountered an issue with grpc-web when we used websocket as the transport layer.
The problem is if user is on mobile device and put the app to background for 10 minutes more or so.
When user active the tab again, the websocket already dead and since it's killed while Javascript is asleep.
I believe the 'onTransportEnd' method don't run.
I have a callback to reconnect websocket in when `end` is triggered. in this case the callback didn't run.
Is there anyway to get the status of websocket from the current implementation of grpc-web?
The problem is quite common and easy to solve by exposing websockets, or just a method to get the status of websockets.
For example:
```
document.addEventListener("visibilitychange", () => {
if(document.visibility === 'visible') {
// get the status of each websocket connection and reconnect if it dies
}
})
```
Contributor guide
Research direction
Start by reading the websocket transport implementation and the onTransportEnd callback behavior described in the issue. Reproduce the mobile or background-tab case, then determine how websocket status should be exposed or reported so a visibilitychange handler can detect a dead connection and reconnect it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- grpc, javascript
- Domain
- api, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100