-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
rtp forward with ipv6 udp socket does not work on macos #2051
Comments
Your suggestion will always create an IPv4 socket. Won't that fail if we need to send to IPv6? A better solution probably is to anticipate the host resolution part, so that when it comes to creating the socket we know what we're sending to and we know what we should create. A pull request would be welcome, thanks! |
Yes you are right, the change I made for now is a local hack to get my system to work. The proper fix is to check the server address and create the socket based on that. I will submit a PR soon. |
#2053 created this PR. I didn't realize that there is a single udp socket and multiple addresses to send to, so the PR is slightly more complicated to handle this situation. |
Looking at your test code, it looks like we won't be able to just add a check on whether |
I made a patch for FreeBSD trying to solve the same problem: -- transports/janus_websockets.c.orig 2020-06-01 08:39:34 UTC
+++ transports/janus_websockets.c
@@ -274,7 +274,7 @@ static const char *janus_websockets_reason_string(enum
#if (LWS_LIBRARY_VERSION_MAJOR >= 4)
static lws_retry_bo_t pingpong = { 0 };
#endif
-
+struct in_addr addr;
/* Helper method to return the interface associated with a local IP address */
static char *janus_websockets_get_interface_name(const char *ip) {
struct ifaddrs *addrs = NULL, *iap = NULL;
@@ -553,13 +553,6 @@ int janus_websockets_init(janus_transport_callbacks *c
/* Force single-thread server */
wscinfo.count_threads = 1;
- /* Create the base context */
- wsc = lws_create_context(&wscinfo);
- if(wsc == NULL) {
- JANUS_LOG(LOG_ERR, "Error creating libwebsockets context...\n");
- janus_config_destroy(config);
- return -1; /* No point in keeping the plugin loaded */
- }
/* Setup the Janus API WebSockets server(s) */
item = janus_config_get(config, config_general, janus_config_type_item, "ws");
@@ -580,12 +573,22 @@ int janus_websockets_init(janus_transport_callbacks *c
item = janus_config_get(config, config_general, janus_config_type_item, "ws_ip");
if(item && item->value) {
ip = (char *)item->value;
+ if(inet_net_pton(AF_INET, ip, &addr, sizeof(addr))>0) {
+ wscinfo.options |= LWS_SERVER_OPTION_DISABLE_IPV6;
+ }
char *iface = janus_websockets_get_interface_name(ip);
if(iface == NULL) {
JANUS_LOG(LOG_WARN, "No interface associated with %s? Falling back to no interface...\n", ip);
}
ip = iface;
}
+ /* Create the base context */
+ wsc = lws_create_context(&wscinfo);
+ if(wsc == NULL) {
+ JANUS_LOG(LOG_ERR, "Error creating libwebsockets context...\n");
+ janus_config_destroy(config);
+ return -1; /* No point in keeping the plugin loaded */
+ }
/* Prepare context */
struct lws_context_creation_info info;
memset(&info, 0, sizeof info);
|
Closing as we've already added some IPv6 checks. |
When setting up an RTP forward in the videoroom plugin, janus will create an ipv6 udp socket but then select an ipv4 or ipv6 sockaddr address depending on how the rtp forward was set up. Unfortunately calling sendto() on an ipv6 socket to an ipv4 address does not work on macos. I realize macos is not a first tier citizen in terms of janus support, but it would be a fairly minor change to support macos here.
The setup is that I have a gst-launch-1.0 process listening with a
udpsrc
element on 0.0.0.0:4005, and I create an RTP forward in janus withhost="127.0.0.1"
andport=4005
.The error shows up in the janus log
The following C program also demonstrates the issue
Test this with
The word "test" should show up in the nc output.
On linux the socket can be ipv6 and the address can be ipv4, but on macos the socket and address must both be ipv6 or both be ipv4, otherwise sendto() will return -EINVAL.
The behavior in janus was changed in #1778
I was able to resolve this issue by making the following small change to plugins/janus_videoplugin.c
A more general simple fix is to use the check used elsewhere, which is
if serv_addr.sin_family == AF_INET{ .. do ipv4 stuff .. } else { .. do ipv6 suff .. }
. Would that be a reasonable compromise rather than having some#ifdef MACOS
? I can make a PR for this if so.BTW I also tried having gst-launch-1.0 listen on an ipv6 address rather than ipv4, but gst just dies as soon as it receives the first udp packet from janus.
The text was updated successfully, but these errors were encountered: