Need help for configure AWS load balancer for WCS

Jang

New Member
Hello
We are using AWS EC2 instance for use WCS.
We 've purchase WCS from AWS Market.
So we configured properly and it's working with 1 WCS server only.

Now I am going to configure load balancer for WCS EC2 instances.
I tried with classic load balancer, and network load balancer of AWS.
We are using 8080 (WS) port for load balancing

We created 2 WCS EC2 instance and connect 2 instances with load balancer.

And we tried to use load balancer DNS name instead of EC2 instance DNS name.
But load balancer is not working, even load balancer health check is "healthy".

1614063622870.png


We are getting above error when tried with load balancer DNS name.

Could you please assist?
Thank you
 

Jang

New Member
FYI
When I use load balancer DNS for WS URL( for example ws://nlb-wcs-XXXXXXXXXXXXX.elb.ap-southeast-1.amazonaws.com:8080) it is sometimes work, but sometimes not working and shows below error:


1614069097650.png


But when I use EC2 instance DNS for WS URL without load balancer( for example ws://ec2-XX-XX-XX-XX.ap-southeast-1.compute.amazonaws.com:8080), it works every time and really fine. not sure why load balancer only not working sometimes.

Is there anyway how can I troubleshoot what the main issue?
Thanks
 

Max

Administrator
Staff member
We are getting above error when tried with load balancer DNS name.
Seems like you are using HTTP to open example page and WS to connect to server via load balancer. You have to use HTTPS and WSS for WebRTC to work. So configure Load Banacer to listen WSS port 8443, open example page via HTTPS and connect to WSS port, this should work.
 

Jang

New Member
Hi @Max
Thank you for your reply.
Yes, we are using WS instead of WSS
And we are not using example page, we only use websocket. our main purpose is show live video to website from rtsp source.

So we are using your sample websdk @flashphoner\websdk-2.0.165\examples\demo\streaming\embed_player
In this case, it no need any http or https
only need WS or WSS

So I tried WS(8080) and MediaProvider=MSE, and stream is RTSP

Below is my code
1614147863417.png


And even I use load balancer WS, it works. But problem is sometimes stuck in loading and shows below error:

1614147964422.png


If it is any SSL problem, it should be not working every time. But only sometimes it doesn't work.

Please advice what is wrong in my case
Thank you
 

Max

Administrator
Staff member
Please clarify:
- what browsers do you use?
- how do you open the page where Embed Player is embedded?
- how do you open Embed Player page to embed?
Please also check if the case works if only one instance is behind the load balancer
 

Jang

New Member
-what browsers do you use?
I am using google chrome

-how do you open the page where Embed Player is embedded?
-how do you open Embed Player page to embed?

I am using sample of web sdk

Here I am using @flashphoner\websdk-2.0.165\examples\demo\streaming\embed_player , this folder.
In this folder, there is player.js
I changed player.js like this manually.

1614156847904.png


And run player.html in google chrome.
I am testing with 3 URLs(load balancer with 3 instance, load balancer with 1 instance, EC2 instance directly).

only 1st case : load balancer with 3 instance is not working, this case also work sometimes, but sometimes not work and failed.

-please also check if the case works if only one instance is behind the load balancer.
If only one instance is behind the load balancer, then no problem, only problem from 2 more+
 

Max

Administrator
Staff member
only 1st case : load balancer with 3 instance is not working, this case also work sometimes, but sometimes not work and failed.
Thank you for case explanation.
Unfortunately, MSE or WSPlayer is not suitable to play the stream from server behind the load balancer because those technologies both use two websocket connections: one for signaling messages and one for stream binary data. So load balancer is randomly routes connections to a different servers behind it.
So you have to use either WebRTC (and secure connections) in Embed Player or HLS in some HLS player (there are three examples: HLS VideoJS, HLS.js and HLS native for Apple devices).
 

Jang

New Member
Thank you for your info
It seems we need to use WebRTC with secure TCP.
It means I need create certificate and install it in each EC2 instances, right?
Do you have any references and documents for to do it?
 

Jang

New Member
In WCS admin panel, there is certificate menu which can upload certificate.
1614171060159.png


If I create certificate from domain provider and upload it via this admin panel, this will work for websocket as well?
This will be solution?

Thank you
 

Max

Administrator
Staff member
It means I need create certificate and install it in each EC2 instances, right?
If you plan to use instances directly, yes.
But if your viewers will access instances via load balancer only, it is enough to set up load balancer to listen WSS port 8443 (or 443), assign domain name and SSL certificate to load balancer only. The AWS LB creation wizard should ask you about certificates if you choose secure connection.
Please note that you can forward 8443 LB port to 8080 instance port.
Do you have any references and documents for to do it?
Please read how to import SSL certificates to WCS here
If I create certificate from domain provider and upload it via this admin panel, this will work for websocket as well?
Yes, this will work for websocket and HTTPS connections.
 
Top