Comments (14)
#78
I looked at previous feedback with the same problem, but it doesn't seem to be fixed
from libjuice.
#include "juice/juice.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <windows.h>
static void sleep(unsigned int secs) { Sleep(secs * 1000); }
#else
#include <unistd.h> // for sleep
#endif
#define BUFFER_SIZE 4096
static juice_agent_t* agent;
static void on_state_changed(juice_agent_t* agent, juice_state_t state, void* user_ptr);
static void on_candidate(juice_agent_t* agent, const char* sdp, void* user_ptr);
static void on_gathering_done(juice_agent_t* agent, void* user_ptr);
static void on_recv(juice_agent_t* agent, const char* data, size_t size, void* user_ptr);
static bool isok = false;
void test_connectivity() {
juice_set_log_level(JUICE_LOG_LEVEL_DEBUG);
// Agent 1: Create agent
juice_config_t config;
memset(&config, 0, sizeof(config));
// STUN server
config.stun_server_host = "47.97.100.165";
config.stun_server_port = 3478;
// TURN server
// Please do not use outside of libjuice tests
juice_turn_server_t turn_server;
memset(&turn_server, 0, sizeof(turn_server));
turn_server.host = "47.97.100.165";
turn_server.port = 3478;
turn_server.username = "admin";
turn_server.password = "123456";
config.turn_servers = &turn_server;
config.turn_servers_count = 1;
config.cb_state_changed = on_state_changed;
config.cb_candidate = on_candidate;
config.cb_gathering_done = on_gathering_done;
config.cb_recv = on_recv;
config.user_ptr = NULL;
agent = juice_create(&config);
juice_gather_candidates(agent);
while (isok==false)
{
sleep(1);
}
char localdescription[4096] = {};
char remotedescription[4096] = {};
std::cout << "=================================================================================================" << "\n";
juice_get_local_description(agent, localdescription, sizeof(localdescription));
std::cout << localdescription;
std::cout << "=================================================================================================" << "\n";
std::cin >> remotedescription;
juice_set_remote_description(agent, remotedescription);
}
// Agent 1: on state changed
static void on_state_changed(juice_agent_t* agent, juice_state_t state, void* user_ptr) {
}
// Agent 1: on local candidate gathered
static void on_candidate(juice_agent_t* agent, const char* sdp, void* user_ptr) {
}
// Agent 1: on local candidates gathering done
static void on_gathering_done(juice_agent_t* agent, void* user_ptr) {
isok = true;
}
// Agent 1: on message received
static void on_recv(juice_agent_t* agent, const char* data, size_t size, void* user_ptr) {
}
int main()
{
test_connectivity();
std::cout << "Hello World!\n";
Sleep(99999999);
}
from libjuice.
This is my current usage flow, but there are two problems
-
I collected all the candidates as you said, and only called juice_set_remote_description, but the P2P direct connection always fails.
-
Although direct connection is possible, use relay connection
How to use libjuice correctly
from libjuice.
Thank you for reporting.
There is an issue with how you copy paste descriptions:
std::cin >> remotedescription;
juice_set_remote_description(agent, remotedescription);
The >>
operator will read a single word from input here, so libjuice will get only the beginning of the description. It's actually surprising you get any connectivity. By the way, you should not read from stdin into a buffer without bound checking as it is unsafe (it allows buffer overflow) and instead you should read into a string.
You could read the entire description with repeated calls to getline
until an empty line for instance.
from libjuice.
I know there is something wrong with std::cin . I mainly demonstrate this process. Do you think there is something wrong with my process? And if it is written like this, will there be a role conflict, and whether the juice caused by the role conflict will only be relayed directly
from libjuice.
I have the same problem as he feels, but I still don't know how to fix it
My official project is roughly written according to this calling process, but there will be two problems mentioned above.
from libjuice.
I know there is something wrong with std::cin . I mainly demonstrate this process. Do you think there is something wrong with my process?
Please post the actual code, otherwise I can't help you.
And if it is written like this, will there be a role conflict, and whether the juice caused by the role conflict will only be relayed directly
There will be a role conflict, as one side should first call juice_get_local_description
then juice_set_remote_description
, whereas the other side should call juice_set_remote_description
then juice_get_local_description
. However, the role conflict should not cause relaying.
from libjuice.
#78
May I ask what is the cause of the problem reported in this link, and how to solve it in the end
from libjuice.
controlling_log.txt
controlled_log.txt
Can you see the error in the log of the connection between the two ends?
from libjuice.
Can you see the error in the log of the connection between the two ends?
I see no error. UDP datagrams sent from one side never reach the other, so the controlling side eventually choose the relay.
Could you please send the VERBOSE
log with and without the TURN server?
from libjuice.
p2p_controlled_log.txt
p2p_controlling_log.txt
I want to know how to improve the success rate of p2p penetration by using libjuice. Now my success rate is very low, perhaps only 5%. But I tested other p2p penetration tools, the same two computers, with a success rate of% 95
from libjuice.
Tell me how to use libjuice to improve the success rate of p2p nat penetration
from libjuice.
I don't understand, at first you said "If TRUN is not set when Juice is created, 90% of P2P direct connections are successful" now you say "my success rate is very low, perhaps only 5%".
The log without TURN also show a direct connection failure where datagrams from one side never reach the other. How do you pass the descriptions from one computer to the other? If it takes more than a few seconds, NAT traversal might fail.
from libjuice.
I think you should write a test example of the public network p2p nat. The local example is useless because the local itself can connect directly
from libjuice.
Related Issues (20)
- Does juice_add_remote_candidate have to be called p2p in on_candidate or on_gathering_done callback to be effective? HOT 4
- Re-licensing under MPL 2.0 HOT 5
- juice_server_add_credentials How to use it correctly? It has no effect HOT 5
- How does libjuice do multiple connections HOT 1
- Call the libjuice library, call the library in cpp, the memory occupies 4M, call the library in pure C, the memory occupies 2.5M,Why? HOT 2
- Can libjuice support candidates re-gathering? HOT 2
- On MacOS, with M1/2 Apple Silicon, there's a risk of the receiving threads running at very low performance
- double deallocation when allocation fails HOT 1
- usage clarification HOT 5
- Failed to compile on embedded arm architecture platform HOT 2
- ICE-TCP HOT 3
- Add single-threaded mode HOT 11
- STUN message send failed / STUN local ufrag check failed. HOT 4
- STUN Freshness Issue Leads to Disconnects HOT 4
- STUN security considerations - STUN over DTLS ? HOT 2
- Building juice-static on Windows results in a static library that looks to be compiled for a dynamically linked C runtime HOT 2
- Integrate into `asio::io_service` on C++ application HOT 1
- io_uring and libjuice HOT 2
- Misalignment issue during STUN data reading HOT 3
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 libjuice.