Mediasoup only working on local network

Hi! First of all thank you for this amazing software!

I successfully tested in my lan today, and it worked like a charm on every mobile phone/browser i tested. I then tried to run it on my server, and now the problems began.

I have developed a signaling server with socket.io/node running on port 8089 on my AWS EC2 server, it’s proxied by NGINX, so on my client code i simply point to the signaling server to https://myserver:443/ and it redirects the requests and connection upgrade etc.

I’ve allowed ports 40000 - 49999 both UPD and TCP on my security group.

My server has a public domain (elastic ip in AWS naming convention) so my initial thought was to (according to the faq and documentation) use my public ip in the listenIps. { ip: ‘18.228.158.64’, announcedIp: null }

It turned out that it won’t work and will raise an exception in the server:

UnhandledPromiseRejectionWarning: Error: port bind failed due to address not available [transport:udp, ip:‘18.228.158.64’, port:40937, attempt:1/10000]

If I use { ip: ‘127.0.0.1’, announcedIp: ‘18.228.158.64’ } it will not raise this exception BUT it simply won’t

transport ea3b14c1-cd46-49c8-b2b6-599a71a8b79c connectionstatechange connecting…
transport connstate connecting
transport 388a61aa-e55b-46bd-8157-1a3b840d3043 connectionstatechange failed
transport closed … leaving the room and resetting
transport connstate closed

I know it is not code related because it is working at this very moment in my local network. It is just in the server that it wont work =(. I even tried using multiple listenIps but no luck!

Is it a known bug? Any guidance is much appreciated!

Thank you

Not a bug. You should diagnose why you cannot reach that port from outside. This is always a routing/networking/iptables issue.

You should have routing rules enabled in place, for example traffic coming on ports 40000-49999 of ip 18.228.158.64 should be directed to your private server on which mediasoup runs.

Thank you for your reply!

Oh ok, I’ll give it a look. Maybe Ubuntu has its udp ports blocked through its default firewall.
It never occurred to me that it could be the problem, because the routing is made by Amazon. All it takes is unblocking the ports from the aws console management which i did and usually do to any other software. I use nodejs, nginx, icecast. It all worked out of the box by doing this process. I can then access any service through its public_ip:port.

It was the first time such a problem occurred.

The firewall is disabled

$ sudo ufw status
Status: inactive

There are no iptables restricting access to the server
$ sudo iptables -S

-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT

As said earlier, amazon handles all the routing from my public ip to my server, any software that i run on my server is accessible through public_ip:port. All it takes is unblocking the ports in my security group through amazon aws console management. The ports are open, the server where mediasouop runs on is accessible through public_ip. I think this is something else, why wouldn’t mediasouop behave like any other software? Even Janus worked out of the box, I don’t know where else to look for as i tried all possible listenIps combinations.

I suspected it could be related to the fact im proxying nodejs (signaling server) through nginx using a SSL connection and maybe (when not running on my local network) the mediasoup-client api fails to establish an encrypted connection to mediasoup server directly?

Should I file a bug report as this is really weird?

Blaming mediasoup. Not the first one today. You can use Janus if you wish.

No, i decided to use MediaSoup because it is a lot better in terms of performance, code, community. Janus founder is unfortunately too impolite and arrogant. Plus, in my local network mediasoup worked so well, it is very imrpessive!

Dont take me wrong, im just trying to help actually. And be helped as well because there is something else , im not blaming it.

I am running a udp server on my server now on port 40000.
$ nc -u -l 40000

You can access it through my public ip like this:
nc -u 18.228.158.64 40000

You can type and i receive everything on my server… UPD ports and IP are right, network is right. It may be either a bug or a listenIps configuration error.Im using all of this three possibilities:

{ ip: ‘18.228.158.64’, announcedIp: null },
{ ip: ‘172.31.15.203’, announcedIp: null },
{ ip: ‘127.0.0.1’, announcedIp: null }
{ ip: ‘18.228.158.64’, announcedIp: ‘18.228.158.64’},
{ ip: ‘127.0.0.1’, announcedIp: ‘18.228.158.64’},

Tried one by one, two of them, three of them, NOTHING so far works.

I am just trying to make it work, and all i know is it is not network/routing as you can test yourself, the upd server is running now on my server on port 40000.

You are using AWS so you need announcedIp. Said that, try with listenIp “0.0.0.0” or your real private IP (the one you have not tried yet because there is no ifconfig output in your comments).

Thank you for your reply Iñaki. Maybe that is the only possible setup i haven’t tried. My private ip i used above but not in combination with announcedIp.

ifconfig gives me this (that ip i used before but not in combination with announcedIp).

$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 9001
inet 172.31.15.203 netmask 255.255.240.0 broadcast 172.31.15.255
inet6 fe80::15:b2ff:feea:503a prefixlen 64 scopeid 0x20
ether 02:15:b2:ea:50:3a txqueuelen 1000 (Ethernet)
RX packets 95897932 bytes 117562272273 (117.5 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 107360677 bytes 17713758396 (17.7 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 44476931 bytes 12075735860 (12.0 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 44476931 bytes 12075735860 (12.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

You mean it

PRIVATE IP and PUBLIC IP
{ ip: ‘172.31.15.203’, announcedIp:‘18.228.158.64’ },

Or it

0.0.0.0 and PUBLIC IP
{ ip: ‘0.0.0.0’, announcedIp:‘18.228.158.64’ },

Or maybe it then
0.0.0.0 and private ip
{ ip: ‘0.0.0.0’, announcedIp:‘172.31.15.203’ },

I’ll try these options. Thank you for your help!

Please don’t try random things. Your clients need to know your media server ICE public IP, so you have to put your public IP into announcedIp.

1 Like

THANK YOU SO MUCH Iñaki! IT WORKED!

This did the trick
AWS PRIVATE IP and announcedIp PUBLIC ELASTIC IP
{ ip: ‘172.31.15.203’, announcedIp: ‘18.228.158.64’ },

Sorry if i sounded like i was blaming MediaSoup. I can’t criticise something I can’t make. It works really well, it has from far the best documentation, I just needed help with the configuration, and your guidance helped me.

Congratulations for this grate piece of software, I’m developing a Virtual Reality massive world and I’d be interested in partnering with your company if things start to scale. We were almost going for Vivox which costs around 2.500 USD /month.

If we notice spikes and necessity for a quick horizontal scaling, I’ll let you know. We’d be happy to have a support contract plus being a sponsor.

Have a great week amigo!

Greetings from Brazil

He is a friend and he is not such things. He runs a software run by many companies and individuals and maintains a community around it, not an easy task even more considering the human factor.

You will find us unpolite and arrogant too depending on the context.

5 Likes

hi naiteon, I set AWS PRIVATE IP and announcedIP PUBLIC ELASTIC IP but it still doesn’t working, do you help me ?

Of course! HAve you opened the node js tcp port in the security group used by your VPS? You also need to open the UDP port range you specify, for me it was 40000 up to 49999.

Could you please explain more? Do you use static IP in announcedIP or you used your NAT IP? I’m using lightsail and the problem I have is how to forward these ports from public to private IP.

Hi, this is what i’ve done

AWS PRIVATE IP and announcedIp PUBLIC ELASTIC IP
{ ip: ‘172.31.15.203’, announcedIp: ‘18.228.158.64’ },

in the IP section you have to specify the IP of the aws machine you are using (the LAN address that you get from a instance using ipconfig “private”). In the accouncedIp i use the external IP (my elastic IP) the IP you use remotely to access your instance “public”.

After that you need to allow the range of ports you are using in your config file.

Hi @naiteon,
Thanks for initiating this thread.
I have been looking for some support to setup mediasoup in a AWS Ubuntu instance.

After all the configurations mentioned in the documentation,
I am facing with the below error while hosting my media soup application.

"DOMException: Failed to execute ‘setRemoteDescription’ on ‘RTCPeerConnection’: Failed to set remote answer sdp: The order of m-lines in answer doesn’t match order in offer. Rejecting answer. “Failed to execute ‘setRemoteDescription’ on ‘RTCPeerConnection’: Failed to set remote answer sdp: The order of m-lines in answer doesn’t match order in offer. Rejecting answer.” “Error: Failed to execute ‘setRemoteDescription’ on ‘RTCPeerConnection’: Failed to set remote answer sdp: The order of m-lines in answer doesn’t match order in offer. Rejecting answer.”

Here is my settings on my config file:
{
“LOGGER_SETTINGS”: {
“level”: “debug”,
“silence”: [
“healthz”
]
},
“APP_SETTINGS”: {
“appPort”: 8085,
“wssPort”: 5225,
“swaggerScheme”: “http”,
“client”: {
“client_id”: “”,
“client_secret”: “”
},
“sslCrt”: “”,
“sslKey”: “”
},
“CORS_SETTINGS”: {
“allowedOrigins”: [],
“allowedMethods”: [
“GET”,
“POST”,
“PUT”,
“PATCH”,
“OPTIONS”
],
“allowedCredentials”: false,
“allowedHeaders”: [
“Content-Type”,
“Content-Language”,
“Authorization”,
“X-Authorization”,
“Origin”,
“Accept”,
“Accept-Language”
]
},
“MEDIASOUP_SETTINGS”: {
“workerPool”: 3,
“worker”: {
“rtcMinPort”: 10000,
“rtcMaxPort”: 10100,
“logLevel”: “debug”,
“logTags”: [
“info”,
“ice”,
“dtls”,
“rtp”,
“srtp”,
“rtcp”
]
},
“router”: {
“mediaCodecs”: [
{
“kind”: “audio”,
“mimeType”: “audio/opus”,
“clockRate”: 48000,
“channels”: 2
},
{
“kind”: “video”,
“mimeType”: “video/VP8”,
“clockRate”: 90000,
“parameters”: {
“x-google-start-bitrate”: 1000
}
}
]
},
“webRtcTransport”: {
“listenIps”: [
{
“ip”: “<private ip of my AWS Instance”,
“announcedIp”: null
}
],
“initialAvailableOutgoingBitrate”: 100000,
“minimumAvailableOutgoingBitrate”: 15000,
“maximumAvailableOutgoingBitrate”: 200000,
“factorIncomingBitrate”: 0.75
}

Kindly let me know what am i missing in the configuration.

I have enabled 8085, 5225, 10000-10100 in both udp and tcp from my AWS console.

Thanks in advance.