-
Notifications
You must be signed in to change notification settings - Fork 237
Feat/Trickle ice #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/Trickle ice #336
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Files not reviewed (2)
- ui/package-lock.json: Language not supported
- ui/package.json: Language not supported
Comments suppressed due to low confidence (3)
web.go:129
- Consider renaming 'handLocalWebRTCSignal' to 'handleLocalWebRTCSignal' for clarity and consistency with naming conventions.
func handLocalWebRTCSignal(c *gin.Context) {
ui/src/routes/devices.$id.tsx:290
- Use strict equality (===) instead of the loose equality (==) when comparing the message type.
isSettingRemoteAnswerPending.current = parsedMessage.type == "answer";
cloud.go:78
- The help string for 'metricConnectionTotalPingCount' appears to be incomplete; consider updating it to provide a full description.
Help: "The total number of pings sent to the",
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Files not reviewed (2)
- ui/package-lock.json: Language not supported
- ui/package.json: Language not supported
Comments suppressed due to low confidence (4)
ui/src/routes/devices.$id.tsx:235
- [nitpick] Consider updating the log message to 'isOnDevice' for consistency in casing.
console.log("isondevice", isOnDevice);
ui/src/routes/devices.$id.tsx:410
- [nitpick] Consider using the unified 'peerConnectionState' variable in the dependency array rather than mixing state references.
peerConnection?.signalingState,
ui/src/routes/devices.$id.tsx:261
- [nitpick] Consider using a dedicated logger instead of console.log for error handling in the onError callback to maintain consistency with the rest of the code.
onError(event) { console.log("[Websocket] onError", event); ... }
cloud.go:77
- [nitpick] Consider updating the metric help description to clearly indicate its purpose (for example, 'The total number of ping messages sent over the connection').
Name: "jetkvm_connection_total_ping_count",
…ent for better UI structure
…ipt for debug version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 10 changed files in this pull request and generated no comments.
Files not reviewed (2)
- ui/package-lock.json: Language not supported
- ui/package.json: Language not supported
Comments suppressed due to low confidence (1)
cloud.go:286
- [nitpick] Using an empty string for the source label in cloud connections may reduce metric observability granularity. Consider using a specific identifier (e.g., 'cloud-default') to improve metric labeling.
wsResetMetrics(true, "cloud", "")
* feat(cloud): Use Websocket signaling in cloud mode * refactor: Enhance WebRTC signaling and connection handling * refactor: Improve WebRTC connection management and logging in KvmIdRoute * refactor: Update PeerConnectionDisconnectedOverlay to use Card component for better UI structure * refactor: Standardize metric naming and improve websocket logging * refactor: Rename WebRTC signaling functions and update deployment script for debug version * fix: Handle error when writing new ICE candidate to WebRTC signaling channel * refactor: Rename signaling handler function for clarity * refactor: Remove old http local http endpoint * refactor: Improve metric help text and standardize comparison operator in KvmIdRoute * chore(websocket): use MetricVec instead of Metric to store metrics * fix conflicts * fix: use wss when the page is served over https * feat: Add app version header and update WebRTC signaling endpoint * fix: Handle error when writing device metadata to WebRTC signaling channel --------- Co-authored-by: Siyuan Miao <i@xswan.net>
* feat(cloud): Use Websocket signaling in cloud mode * refactor: Enhance WebRTC signaling and connection handling * refactor: Improve WebRTC connection management and logging in KvmIdRoute * refactor: Update PeerConnectionDisconnectedOverlay to use Card component for better UI structure * refactor: Standardize metric naming and improve websocket logging * refactor: Rename WebRTC signaling functions and update deployment script for debug version * fix: Handle error when writing new ICE candidate to WebRTC signaling channel * refactor: Rename signaling handler function for clarity * refactor: Remove old http local http endpoint * refactor: Improve metric help text and standardize comparison operator in KvmIdRoute * chore(websocket): use MetricVec instead of Metric to store metrics * fix conflicts * fix: use wss when the page is served over https * feat: Add app version header and update WebRTC signaling endpoint * fix: Handle error when writing device metadata to WebRTC signaling channel --------- Co-authored-by: Siyuan Miao <i@xswan.net>
* feat(cloud): Use Websocket signaling in cloud mode * refactor: Enhance WebRTC signaling and connection handling * refactor: Improve WebRTC connection management and logging in KvmIdRoute * refactor: Update PeerConnectionDisconnectedOverlay to use Card component for better UI structure * refactor: Standardize metric naming and improve websocket logging * refactor: Rename WebRTC signaling functions and update deployment script for debug version * fix: Handle error when writing new ICE candidate to WebRTC signaling channel * refactor: Rename signaling handler function for clarity * refactor: Remove old http local http endpoint * refactor: Improve metric help text and standardize comparison operator in KvmIdRoute * chore(websocket): use MetricVec instead of Metric to store metrics * fix conflicts * fix: use wss when the page is served over https * feat: Add app version header and update WebRTC signaling endpoint * fix: Handle error when writing device metadata to WebRTC signaling channel --------- Co-authored-by: Siyuan Miao <i@xswan.net>
Previously, the device connected to the cloud API with a WebSocket and just waited. On the client side, the browser would create a peer connection, gather all ICE candidates, then send a long-running HTTP request to the API. The API would look up the right WebSocket connection, forward the session description from the HTTP request, and wait for a response over WS - all while keeping the HTTP request open. Once the device sent back the remote session description over WS, the HTTP request would return it. This setup was a bit fragile.
In local mode, we just did that HTTP request to the device, and it responded with the remote session description.
With this implementation, we implement what MDN calls the perfect negotiation pattern which does Trickle ICE. Instead of waiting for all the ICE candidates, we simply send them once they are ready. For this, we need 2-way communication, so both peers can update each other at any given time.
We chose WebSocket as the transport layer. In cloud mode, the Cloud API now just proxies WebSocket messages - no more long-running HTTP. In local mode, the device runs its own WebSocket server, and the client connects directly to it.
In addition to implementing "Trickle ICE", we also added:
Overall, this will at best solve a lot of the standing connection issues, at worst it will give us a lot of troubleshooting opportunity with the new logs.
Note:
Create in draft mode, but the branch in fully testable - no major changes expected