# Mediasoup only working on local network

**URL:** <https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453>\
**Category:** Deployment & Scalability\
**Created:** [July 20, 2020, 8:08am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453 "2020-07-20T08:08:49Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [July 20, 2020, 8:08am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/1 "2020-07-20T08:08:49Z")

</div>

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](http://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/](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

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [July 20, 2020, 9:06am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/2 "2020-07-20T09:06:51Z")

</div>

> [@naiteon](#):
>
> Is it a known bug?

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

---

<div class="post-metadata">

**Author:** ![madabhaviamit](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/madabhaviamit/32/1418_2.png) [@madabhaviamit](https://mediasoup.discourse.group/u/madabhaviamit)\
**Post date:** [July 20, 2020, 2:06pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/3 "2020-07-20T14:06:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [July 20, 2020, 3:52pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/4 "2020-07-20T15:52:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [July 20, 2020, 4:23pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/5 "2020-07-20T16:23:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [July 20, 2020, 4:30pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/6 "2020-07-20T16:30:04Z")

</div>

> [@naiteon](#):
>
> why wouldn’t mediasouop behave like any other software? Even Janus worked out of the box

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

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [July 20, 2020, 4:35pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/7 "2020-07-20T16:35:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [July 20, 2020, 5:11pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/8 "2020-07-20T17:11:03Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [July 20, 2020, 5:26pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/9 "2020-07-20T17:26:30Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [July 20, 2020, 5:33pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/10 "2020-07-20T17:33:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [July 20, 2020, 5:41pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/11 "2020-07-20T17:41:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jmillan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/jmillan/32/9_2.png) [@jmillan](https://mediasoup.discourse.group/u/jmillan)\
**Post date:** [July 22, 2020, 8:01am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/12 "2020-07-22T08:01:41Z")

</div>

> [@naiteon](#):
>
> Janus founder is unfortunately too impolite and arrogant. Plus, in my local network mediasoup worked so well,

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.

---

<div class="post-metadata">

**Author:** ![TrungyuD](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/trungyud/32/740_2.png) [@TrungyuD](https://mediasoup.discourse.group/u/TrungyuD)\
**Post date:** [January 5, 2021, 8:37am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/13 "2021-01-05T08:37:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [March 14, 2021, 2:10am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/14 "2021-03-14T02:10:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Assem](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@Assem](https://mediasoup.discourse.group/u/Assem)\
**Post date:** [March 22, 2021, 7:18pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/15 "2021-03-22T19:18:08Z")

</div>

> [@naiteon](#):
>
> PUBLIC ELASTIC IP

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.

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [March 23, 2021, 12:01pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/16 "2021-03-23T12:01:43Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![naiteon](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/naiteon/32/497_2.png) [@naiteon](https://mediasoup.discourse.group/u/naiteon)\
**Post date:** [March 23, 2021, 12:02pm UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/17 "2021-03-23T12:02:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![vigneshwar.v](https://avatars.discourse-cdn.com/v4/letter/v/b77776/32.png) [@vigneshwar.v](https://mediasoup.discourse.group/u/vigneshwar.v)\
**Post date:** [April 20, 2021, 7:42am UTC](https://mediasoup.discourse.group/t/mediasoup-only-working-on-local-network/1453/18 "2021-04-20T07:42:07Z")

</div>

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.
