Comments (5)
I think the issue comes from the way you handle candidates: each side outputs one description but multiple candidates. It seems your code will override each candidate by the next in the candidate box and as a result only display the last one.
There is a semantic subtlety in the API: the methods are called setRemoteDescription
(as there is only one so it will replace the remote description) and addRemoteCandidate
(as it will add one more candidate to the list, not replace existing candidates).
This seems to be because the ICE candidates are already enumerated in the localdescription SDP. When I call WEBRTC.peerConnection[1].localDescription.sdp from the console I also get this version of the answer. However, I am unable to obtain the same localdescription using this library. Is there a way this is easily achieved?
This can be done. You just need to wait for GatheringState
to be Complete
, then you can retrieve the local description with all candidates by calling pc->localDescription()
. This method, called non-trickle ICE, allows for an simpler signaling as it does not require exchanging candidates, only the descriptions, but it could introduce delays if a STUN/TURN server is unreachable.
from datachannel-wasm.
Indeed by appending the candidates to the textbox I was able to set up a working datachannel.
I also now check the GatheringState
if it is complete after which the description is automatically put in the textbox.
pc->onGatheringStateChange([](rtc::PeerConnection::GatheringState state) {
std::cout << "[Gathering State: " << toString(state) << "]" << std::endl;
if(state == rtc::PeerConnection::GatheringState::Complete) {
std::optional<rtc::Description> desc = pc->localDescription();
if(desc.has_value()) {
putDescriptionInOfferBox(rtc::string(desc.value()).c_str());
}
}
});
from datachannel-wasm.
Did you publish the working example?
from datachannel-wasm.
@paullouisageneau could you explain that into a little more detail?
The original issue was that only the last candidate was displayed in the candidate textbox, other candidates were dropped. This is unrelated to what you experience here as your example is not copy paste, and you don't trickle candidates, you wait for gathering complete to send descriptions with candidates.
I tried to make a similar connection establishment based on your copy-paste example, with the only difference that I use a WebSocket server and no copy/paste. My connection works on Firefox, but not on Chrome (same issue as above).
My code in a simplified version: [...]
The code has a bunch of issues but I don't know if it's because it's "simplified" or not: pc
is a local object so it will be destroyed as soon as you leave the init_peer_connection()
function, the type is not sent over the websocket but it is received it somehow, anser
is written instead of anwser
, a callback is set on dc
instead of _dc
...
You have to debug your code and check you transmit the descriptions back and forth correctly. Note it is not good practice to assume and hardcode description type, instead you should get it from description.typeString()
and transmit it.
from datachannel-wasm.
These issues are just because of trying to simplify the code. So I guess you can't see an obvious mistake in the way i handle candidates, ... etc.
Thank you for your input and response.
from datachannel-wasm.
Related Issues (20)
- suggestion about removing libdatachannel as a submodule HOT 2
- Usage of IceServer as a struct in Configuration HOT 1
- Concerns about Async operations HOT 4
- About using stringToUTF8 instead of allocUTF8FromString in webrtc.js and websocket.js HOT 2
- AS option? HOT 19
- onBufferedAmountLow is annoying HOT 11
- Missing rtc* functions during linking HOT 5
- how to use? can i use this in some embed v8 env to support wrtc? HOT 3
- Failed to execute 'createDataChannel' on 'RTCPeerConnection': RTCDataChannel cannot have both max retransmits and max lifetime HOT 10
- RuntimeError: Aborted(free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS) HOT 6
- ServiceWorker datachannel-wasm <=> window native datachannel HOT 3
- usecase HOT 3
- Nodejs support HOT 3
- datachannel-wasm with C based code HOT 4
- send Bytes over DataChannel HOT 3
- Align reliability API with the new API in libdatachannel
- Using Multithreading HOT 2
- support media transport HOT 1
- Match libdatachannel's reliability.hpp HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datachannel-wasm.