How can I debug session.createStream function ?

Dani

Member
I have this function but when it fails - it doesn't reach the first console.log and I can't tell why it's failing.
how can I debug this ?


session = Flashphoner.getSessions()[0];
session.createStream(optionsStreamVid).on(STREAM_STATUS.PUBLISHING, function (streamOutV) {
streamOutVid = streamOutV;
console.log("PUBLISHING streamingVideo - streamOutVidName show: " + streamOutName);
mediaSessionId = streamOutV.id();
console.log("mediaSessionId: " + mediaSessionId);
}).
on(STREAM_STATUS.UNPUBLISHED, function () {
console.log("UNPUBLISHED startStreaming");


}).on(STREAM_STATUS.FAILED, function () {
console.log("FAILED startStreaming ");


}).publish();
 

Max

Administrator
Staff member
Good day.
I have this function but when it fails - it doesn't reach the first console.log and I can't tell why it's failing.
Please clarify where is the first console.log[/ICODE} call you expect to reach in your code? If you expect to receive [ICODE]STREAM_STATUS.PUBLISHING event, but receiving STREAM_STATUS.FAILED, use stream.getInfo() method to get a reason to fail the publishing. Please see the source example on GitHub
Code:
                switch(stream.getInfo()){
                    case STREAM_STATUS_INFO.STREAM_NAME_ALREADY_IN_USE:
                        $("#publishInfo").text("Server already has a publish stream with the same name, try using different one").attr("class", "text-muted");
                        break;
                    case ERROR_INFO.LOCAL_ERROR:
                        $("#publishInfo").text("Browser error detected: " + stream.getErrorInfo()).attr("class", "text-muted");
                        break;
                    default:
                        $("#publishInfo").text("Other: "+stream.getInfo()).attr("class", "text-muted");
                        break;
                }
Check also server logs for possible reason to fail.
You can also enable debug logging in WebSDK functions if you suppose the problem at browser side:
Code:
Flashphoner.init({logger: {severity: "DEBUG"}});
 

Max

Administrator
Staff member
other: Failed by ICE timeout
This means media ports (31001-32000/udp by default) on the server are unreachable. To fix this, check the following:
1. Are the ports opened for outgoing connections on client side?
2. If the server is not behind NAT, are the ports opened for incoming connections in firewall settings?
3. If the server is behind NAT:
3.1. Check if the WCS IP configuration parameters are set as follows:
Code:
ip=<external (router) IP address>
ip_local=<internal (LAN) IP address>
Please see also this doc: Discovering IP addresses in case of NAT
3.2. Check if media ports are forwarded from router to WCS instance
 

Dani

Member
The server is reachable, as all the clients can connect but one -
believe it is a NAT issue, but it's on the client side. I've installed a VPN on the client and the issue was resolved.
Question - is there a way to resolve this without VPN ? The client wasn't aware of the NAT (it was the ip he got from the ISP).
 

Max

Administrator
Staff member
believe it is a NAT issue, but it's on the client side. I've installed a VPN on the client and the issue was resolved.
Question - is there a way to resolve this without VPN ? The client wasn't aware of the NAT (it was the ip he got from the ISP).
Please try to use TURN server to bypass NAT issues at client side.
Another option is to enable TCP transport for WebRTC (some providers block DTLS UDP traffic to prevent Tor access, but DTLS TCP is still working):
Code:
session.createStream({
    name: streamName,
    display: localVideo,
    ...
    transport: "TCP"
    ...
}).publish();
 
Last edited:

Max

Administrator
Staff member
If I set TCP will it try UDP first and than if fails go to TCP ?
No. Stream will be published using the transport defined only.
You can implement fallback in client code:
1. Try to publish with transport: "UDP"
2. If STREAM_STATUS.FAILED with Failed by ICE timeout is received, try to publish againg with transport: "TCP"
 
Top