Skip to content
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

[RSDK-8293] Pass in Connection to Answerer in WebRTC Server #410

Merged
merged 19 commits into from
Feb 5, 2025

Conversation

bashar-515
Copy link
Member

@bashar-515 bashar-515 commented Jan 30, 2025

This PR allows for a preexisting connection to be passed to the constructor for our WebRTC signaling answerer to use via a dial option.

Testing

4 cases:

@cheukt and I ran the first tests by running viam-server on my laptop while connected to the Viam-Guest WiFi. He ran a client Go script on his laptop connected to the Viam WiFi. The client was able to connect to the robot via WebRTC both times.

  1. client on different network can connect if rdk starts up offline then online (force webrtc option)
  2. client on different network can connect if rdk starts up online then goes offline then online (force webrtc option)
  3. client on same network can connect if rdk starts up offline then online (force webrtc option, but using the internal signaler)
offline-online-internal 4. client on same network can connect if rdk starts up online then goes offline then online (force webrtc option, but using the internal signaler) online-offline-internal

@viambot viambot added the safe to test Mark as safe to test label Jan 30, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 30, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 30, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 30, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 30, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 30, 2025
@bashar-515 bashar-515 requested a review from cheukt January 31, 2025 17:18
@bashar-515 bashar-515 marked this pull request as ready for review January 31, 2025 17:53
Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments but looks pretty good!

@@ -280,3 +283,10 @@ func WithForceDirectGRPC() DialOption {
o.disableDirect = false
})
}

// WithConn provides a preexisting connection to use. This option forces the webrtcSignalingAnswerer to not dial or manage a connection.
func WithConn(conn ClientConn) DialOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe ExternalSignalerConn? we should be clear that this would be used for the external signaler answerer

@@ -71,6 +76,11 @@ func newWebRTCSignalingAnswerer(
bgWorkers: bgWorkers,
logger: logger,
}
if options.conn != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the internal signaler answer shouldn't be using the same connection - it is instantiated here

goutils/rpc/server.go

Lines 659 to 665 in cf6c56e

server.webrtcAnswerers = append(server.webrtcAnswerers, newWebRTCSignalingAnswerer(
address,
internalSignalingHosts,
server.webrtcServer,
answererDialOpts,
config,
utils.Sublogger(logger, "signaler.internal"),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't require any change does it, since its instantiation has its own fresh set of options passed?

@bashar-515 bashar-515 requested a review from cheukt January 31, 2025 18:21
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 31, 2025
@bashar-515 bashar-515 marked this pull request as draft January 31, 2025 18:34
Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks generally good, will hold off on approving until the corresponding RDK pr is in

@@ -280,3 +283,10 @@ func WithForceDirectGRPC() DialOption {
o.disableDirect = false
})
}

// WithConn provides a preexisting connection to use. This option forces the webrtcSignalingAnswerer to not dial or manage a connection.
func WithConn(externalSignalerConn ClientConn) DialOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename WithConn as well

@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Jan 31, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 4, 2025
@bashar-515 bashar-515 requested a review from cheukt February 4, 2025 23:08
Copy link
Member

@cheukt cheukt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion

@@ -64,6 +64,9 @@ type dialOptions struct {
// interceptors
unaryInterceptor grpc.UnaryClientInterceptor
streamInterceptor grpc.StreamClientInterceptor

// conn can be used to force the webrtcSignalingAnswerer to use a preexisting connection instead of dialing and managing its own.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// conn can be used to force the webrtcSignalingAnswerer to use a preexisting connection instead of dialing and managing its own.
// signalingConn can be used to force the webrtcSignalingAnswerer to use a preexisting connection instead of dialing and managing its own.

@viambot viambot added safe to test Mark as safe to test and removed safe to test Mark as safe to test labels Feb 5, 2025
@bashar-515 bashar-515 merged commit ce73676 into viamrobotics:main Feb 5, 2025
6 checks passed
@bashar-515 bashar-515 deleted the RSDK-8293 branch February 5, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test Mark as safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants