paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.81k stars 365 forks source link

client in example #137

Closed alicera closed 4 years ago

alicera commented 4 years ago

libdatachannel/examples/client/ I run the project and it show the message. how to do to run it?

2020-07-31 17:03:00.400 ERROR [3024] [rtc::TcpTransport::runLoop@310] TCP connect: Connection to localhost:8000 failed WebSocket failed: TCP connection failed 2020-07-31 17:03:00.401 DEBUG [3016] [rtc::TcpTransport::stop@100] Waiting for TCP recv thread

paullouisageneau commented 4 years ago

You need to have an example signaling server running in background (either the node.js one, the python one or the rust one). Then you may run two clients and give the id of the first one to the second one so they can connect.

alicera commented 4 years ago

thanks, So the client only can type the " id " ,other messages cant be type ,right?

paullouisageneau commented 4 years ago

Indeed it's not possible by default, however you could modify it to allow typing messages.

alicera commented 4 years ago

I have another problem " connectivity.cpp " and " signaling-server.py " do the same thing? image

connectivity.cpp do the 1~5 "signaling-server.py do the 1 ~ 4 " + " client do the 5 "

paullouisageneau commented 4 years ago

connectivity.cpp do the 1~5 "signaling-server.py do the 1 ~ 4 " + " client do the 5 "

You are right, connectivity.cpp is a connectivity test acting as two clients with a signaling server.

alicera commented 4 years ago

I try to run the web with node server.js I cant type the "remote ID" or "message" in the interface image

paullouisageneau commented 4 years ago

The remote ID input is disabled because the WebSocket failed to connect to signaling server. Please check that the node server is still running and that it didn't encounter any error. You should actually run the example with npm (npm install then npm start).

alicera commented 4 years ago

How to let C++ connect browser without WebSocket Do you have any idea ?

paullouisageneau commented 4 years ago

You can't establish a WebRTC connection without exchanging the descriptions first. It's necessay for firewall and NAT traversal, and for security verifications.

A WebSocket is not required though. You can pass the descriptions through any channel, for instance you could use HTTP polling or server-sent events.

alicera commented 4 years ago

The "libdatachannel/examples/client/" pass the descriptions through websocket, right? "libdatachannel/examples/signaling-server-python/" and "libdatachannel/examples/web/" ,too.

Can the "pass the descriptions through any channel" consider a Signaling Server?

paullouisageneau commented 4 years ago

Yes the examples all use WebSocket, except the copy-paste ones which use the user copy-pasting.

Yes whatever method you use you'll need a server, since the browser can only open connections to a server.

alicera commented 4 years ago

I want to create a signaling server for c++ and "libdatachannel/examples/web/" , instead of websocket. Could you recommend me some method for libdatachannel?

paullouisageneau commented 4 years ago

I guess HTTP POST requests for client-to-server and server-sent events (or HTTP long poll) for server-to-client should work nearly as well as websockets, you should look into that.

alicera commented 4 years ago

Can a signaling server be create by iceServers? For example config.iceServers.emplace_back("stun:stun.l.google.com:19302"); // change to your STUN server

paullouisageneau commented 4 years ago

No that's not possible as they don't allow relaying information like that.

alicera commented 4 years ago
  1. The "libdatachannel/examples/client/" use the WebSocket + ICE(STUN+TURN) to do 5 ?
  2. The "copy-pasting" use the ICE(STUN+TURN) to do 5 ? image
paullouisageneau commented 4 years ago

Yes both do. ICE is always the first part of the datachannel establishment in 5.

alicera commented 4 years ago

I use "config.iceServers.emplace_back("stun.l.google.com:19302");" in offerer.cpp and it show the message """ 2020-08-06 19:40:56.989 WARN [952] [rtc::IceTransport::LogCallback@267] juice: agent.c:1007: STUN message send failed, errno=101 """

alicera commented 4 years ago

If using the websocket as the Signaling Server. Is it possible to exchange SDP for two different IP (client A and client B)?

paullouisageneau commented 4 years ago

2020-08-06 19:40:56.989 WARN [952] [rtc::IceTransport::LogCallback@267] juice: agent.c:1007: STUN message send failed, errno=101

This is just a warning, probably because IPv6 network is not reachable but the STUN server has an IPv6 address. It should still connect fine.

If using the websocket as the Signaling Server. Is it possible to exchange SDP for two different IP (client A and client B)?

What do you mean ?

alicera commented 4 years ago

If using the websocket as the Signaling Server. Is it possible to exchange SDP for two different IP (client A and client B)? change to

If using the websocket as the Signaling Server. Is it possible to exchange SDP for two client and the clients are Public IP

paullouisageneau commented 4 years ago

Sure, that's the principle, you need the signaling server to be hosted on a public IP too and both clients should connect to it to exchange descriptions.

alicera commented 4 years ago

Thanks For Your Help

paullouisageneau commented 4 years ago

You're welcome, I'm closing this if you don't have other issues with the client.

alicera commented 4 years ago

"examples/client" cant offer to "examples/web" But "examples/web" can offer to "examples/client "

paullouisageneau commented 4 years ago

Could you describe the issue please?

alicera commented 4 years ago

ok