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

Abort the relay,I need a demo. #629

Open
luoshuai5 opened this issue Dec 9, 2021 · 9 comments
Open

Abort the relay,I need a demo. #629

luoshuai5 opened this issue Dec 9, 2021 · 9 comments

Comments

@luoshuai5
Copy link

ION-SFU integration

ION-SFU offers some convenience methods for relaying peers in a very simple way.

To relay a peer just call Peer.Publisher().Relay(...) then signal the data to the remote SFU and ingest the data using:

session.AddRelayPeer(peerID string, signalData []byte) ([]byte, error)

set the []byte response from the method as the response of the signaling. And is ready, everytime a peer joins to the new SFU will negotiate the relayed stream.

When will I call Peer.Publisher().Relay(...) ?
When will I call session.AddRelayPeer(peerID string, signalData []byte) ([]byte, error) ?

@upeartaker
Copy link
Contributor

You can try to do it yourself
Try to write an information service, manage all sFU nodes, register your node information in the information service, call other SFU node Relay and AddRelay method through GRPC, Relay communication.

@adwpc
Copy link
Contributor

adwpc commented Dec 19, 2021

@upeartaker Thanks for the answer, i'd like to help if you can PR a example :)

@upeartaker
Copy link
Contributor

Of course, I will propose a PR to you sometime @adwpc

@luoshuai5
Copy link
Author

@upeartaker yes, i done it, but it not work. when a publisher join session, I call Peer.Publisher().Relay(...),then, send the data to other sfu by RPC, other sfu get the data and call session.AddRelayPeer(peerID string, signalData []byte) ([]byte, error).

@upeartaker
Copy link
Contributor

upeartaker commented Dec 20, 2021

Emmm, I think it is possible that your two SFU service exposed UDP port is single port, change to random port try. I have also encountered this problem, in ORTC mode, the relay operation uses a single port, there are some weird problems.

The code I implemented under the signal service looks something like this

                             c, err := NewInvoke(e.Addr, "")
			if err != nil {
				sfu.Logger.Error(err, "init relay grpc invoke failed")
				return status.Errorf(codes.Internal, "join error %s", err)
			}
			_, err = peer.Publisher().Relay(func(meta relay.PeerMeta, signal []byte) ([]byte, error) {
				//	 record
				s.edgeServer.relayServer.AddRelay(&RelayInfo{
					EdgeName: e.EdgeName,
					EdgeAddr: e.Addr,
					Pid:      peer.ID(),
				})
				answer, err := c.AddRelayPeer(s.edgeServer.relayServer.RelayAddr, peer.ID(), payload.Join.Sid, signal)
				if err != nil {
					sfu.Logger.Error(err, "add relay peer grpc invoke failed")
					return nil, err
				}
				return answer, nil
			}, sfu.RelayWithFanOutDataChannels(), sfu.RelayWithSenderReports(), sfu.RelayWithMiddlewareDatachannel())

			if err != nil {
				sfu.Logger.Error(err, "invoke relay method failed")
				return status.Errorf(codes.Internal, "join error %s", err)
			}

invoke is grpc client

@luoshuai5
Copy link
Author

luoshuai5 commented Dec 20, 2021

@upeartaker en, it still not work.
this my code

    p.Publisher().Relay(func(meta relay.PeerMeta, signal []byte) ([]byte, error) {  \n
   		return AddRelay("192.168.1.157:8888", meta.PeerID, meta.SessionID, signal)  // connect to other sfu by RPC \n
   	}, sfu.RelayWithFanOutDataChannels(), sfu.RelayWithSenderReports()) \n

other sfu err log:

2021-12-20 11:11:47.917] [INFO] [main.go:94] => Config file loaded file=config.toml v=0
[2021-12-20 11:11:47.917] [INFO] [main.go:151] => --- Starting SFU Node --- v=0
[2021-12-20 11:11:47.917] [INFO] [main.go:190] => Started listening addr=http://:7000 v=0
[2021-12-20 11:11:47.917] [INFO] [relay.go:37] => Started listening addr=0.0.0.0:8888 v=0
[2021-12-20 11:12:02.378] [INFO] [relay.go:76] => GetSignalData peer=ckxe3r00r0001hsswnnek1s4e session=ion v=0
[2021-12-20 11:12:11.245] [INFO] [peer.go:291] => PeerLocal join SessionLocal peer_id=ckxe3r5kd0000j934ft9fodid session_id=ion v=0
[2021-12-20 11:12:11.245] [INFO] [peer.go:305] => PeerLocal got offer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:316] => PeerLocal send answer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.497] [INFO] [peer.go:239] => Send offer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.499] [INFO] [peer.go:329] => PeerLocal got answer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.500] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.500] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.500] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:32.477] [ERROR] [relay.go:286] => Error starting relay error="connecting canceled by caller"

@upeartaker
Copy link
Contributor

[2021-12-20 11:12:32.477] [ERROR] [relay.go:286] => Error starting relay error="connecting canceled by caller"
@luoshuai5 Your problem appears to be that two SFU nodes are disconnected from the network. I do not know the deployment status of your two SFU nodes. If you are in pod form, try using Host Pod and add NAT1to1 while portrange is on

If that doesn't solve your problem, I suggest you use a packet capture tool to analyze your STUN server mappings

@luoshuai5
Copy link
Author

luoshuai5 commented Dec 20, 2021

@upeartaker all peers and sfu nodes use same LAN.

@sweetbasil-bill
Copy link

@upeartaker en, it still not work. this my code

    p.Publisher().Relay(func(meta relay.PeerMeta, signal []byte) ([]byte, error) {  \n
   		return AddRelay("192.168.1.157:8888", meta.PeerID, meta.SessionID, signal)  // connect to other sfu by RPC \n
   	}, sfu.RelayWithFanOutDataChannels(), sfu.RelayWithSenderReports()) \n

other sfu err log:

2021-12-20 11:11:47.917] [INFO] [main.go:94] => Config file loaded file=config.toml v=0
[2021-12-20 11:11:47.917] [INFO] [main.go:151] => --- Starting SFU Node --- v=0
[2021-12-20 11:11:47.917] [INFO] [main.go:190] => Started listening addr=http://:7000 v=0
[2021-12-20 11:11:47.917] [INFO] [relay.go:37] => Started listening addr=0.0.0.0:8888 v=0
[2021-12-20 11:12:02.378] [INFO] [relay.go:76] => GetSignalData peer=ckxe3r00r0001hsswnnek1s4e session=ion v=0
[2021-12-20 11:12:11.245] [INFO] [peer.go:291] => PeerLocal join SessionLocal peer_id=ckxe3r5kd0000j934ft9fodid session_id=ion v=0
[2021-12-20 11:12:11.245] [INFO] [peer.go:305] => PeerLocal got offer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:316] => PeerLocal send answer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.247] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.497] [INFO] [peer.go:239] => Send offer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.499] [INFO] [peer.go:329] => PeerLocal got answer peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.500] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.500] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:11.500] [INFO] [peer.go:349] => PeerLocal trickle peer_id=ckxe3r5kd0000j934ft9fodid v=0
[2021-12-20 11:12:32.477] [ERROR] [relay.go:286] => Error starting relay error="connecting canceled by caller"

I encountered the same error while playing with SFUa SFUb (connecting canceled by caller), on my SFUa side (the one as local SFU to call peer.Publisher.Relay) the printout is actually something else. (missing uFrag).

and after digging into the detailed response (content of signal returning from remote SFU), for my specific case the failure is parsing the response from remote SFU. So maybe you can check the signal value on both side, hopefully this can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants