Can not connect to wss server(Janus API)

2,855 views
Skip to first unread message

Chen Cong

unread,
Apr 6, 2016, 12:18:42 AM4/6/16
to meetecho-janus
Hi

I have a problem with connecting to wss server(Janus API).

the log in browser is 

WebSocket connection to 'wss://server.realtimecat.com:9000/' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED
janus.js:436 Error connecting to the Janus WebSockets server... wss://server.realtimecat.com:9000/wsHandlers.error @ janus.js:436

I have set "wss = yes" and there was no output log when I connected to wss server.

It is no problem connecting to ws server. 

the log in server is 
---------------------------------------------------
  Starting Meetecho Janus (WebRTC Gateway) v0.1.0
---------------------------------------------------

Checking command line arguments...
Debug/log level is 4
Debug/log timestamps are disabled
Debug/log colors are enabled
Adding 'vmnet' to the ICE ignore list...
Using 123.57.19.192 as local IP...
[WARN] Token based authentication disabled
Initializing ICE stuff (Full mode, ICE-TCP candidates disabled, IPv6 support disabled)
BUNDLE is NOT going to be forced
rtcp-mux is NOT going to be forced
Fingerprint of our certificate: D2:B9:31:8F:DF:24:D8:0E:ED:D2:EF:25:9E:AF:6F:B8:34:AE:53:9C:E6:F3:8F:F2:64:15:FA:E8:7F:53:2D:38
ICE handles watchdog started
Plugins folder: /opt/janus/lib/janus/plugins
Loading plugin 'libjanus_videoroom.so'...
JANUS VideoRoom plugin initialized!
Loading plugin 'libjanus_echotest.so'...
JANUS EchoTest plugin initialized!
Loading plugin 'libjanus_sip.so'...
JANUS SIP plugin initialized!
Loading plugin 'libjanus_audiobridge.so'...
JANUS AudioBridge plugin initialized!
Loading plugin 'libjanus_voicemail.so'...
JANUS VoiceMail plugin initialized!
Loading plugin 'libjanus_streaming.so'...
VideoRoom watchdog started
EchoTest watchdog started
SIP watchdog started
AudioBridge watchdog started
VoiceMail watchdog started
JANUS Streaming plugin initialized!
Loading plugin 'libjanus_videocall.so'...
JANUS VideoCall plugin initialized!
Loading plugin 'libjanus_recordplay.so'...
JANUS Record&Play plugin initialized!
Transport plugins folder: /opt/janus/lib/janus/transports
Loading transport plugin 'libjanus_rabbitmq.so'...
[WARN] RabbitMQ support disabled (Janus API)
[WARN] RabbitMQ support disabled (Admin API)
[WARN] RabbitMQ support disabled for both Janus and Admin API, giving up
Loading transport plugin 'libjanus_websockets.so'...
libwebsockets >= 1.6 available, using new API
VideoCall watchdog started
Record&Play watchdog started
Streaming watchdog started
WebSockets server started (port 8188)...
Secure WebSockets server started (port 9000)...
[WARN] Admin WebSockets server disabled
[WARN] Secure Admin WebSockets server disabled
JANUS WebSockets transport plugin initialized!
Loading transport plugin 'libjanus_http.so'...
HTTP webserver started (port 8088, /janus path listener)...
Secure WebSocket (Janus API) thread started
WebSocket (Janus API) thread started
HTTPS webserver started (port 8089, /janus path listener)...
[WARN] Admin/monitor HTTP webserver disabled
[WARN] Admin/monitor HTTPS webserver disabled
JANUS REST (HTTP/HTTPS) transport plugin initialized!
HTTP/Janus sessions watchdog started
Sessions watchdog started




Thx for your help.

Lorenzo Miniero

unread,
Apr 6, 2016, 7:10:16 AM4/6/16
to meetecho-janus
The server port seems correctly configured, so you should have a look at the network traffic to see what's causing the TCP connection to fail. By the way, are you passing the correct subprotocol when creating the WebSockets connection?

L.

Chen Cong

unread,
Apr 6, 2016, 10:12:00 PM4/6/16
to meetecho-janus
Thx for your reply.

I am not very clear about how TCP works. :(
I used command 
tcpdump -i any port 9000

and got
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
09:58:35.709056 IP 144.168.57.18.16clouds.com.60001 > 123.57.19.192.9000: Flags [S], seq 2581872776, win 14600, options [mss 1460,sackOK,TS val 4265786544 ecr 0,nop,wscale 7], length 0
09:58:35.709100 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60001: Flags [S.], seq 386143097, ack 2581872777, win 28960, options [mss 1460,sackOK,TS val 11092385 ecr 4265786544,nop,wscale 7], length 0
09:58:35.898348 IP 144.168.57.18.16clouds.com.60001 > 123.57.19.192.9000: Flags [.], ack 1, win 115, options [nop,nop,TS val 4265786728 ecr 11092385], length 0
09:58:35.898877 IP 144.168.57.18.16clouds.com.60001 > 123.57.19.192.9000: Flags [P.], seq 1:182, ack 1, win 115, options [nop,nop,TS val 4265786729 ecr 11092385], length 181
09:58:35.898898 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60001: Flags [.], ack 182, win 235, options [nop,nop,TS val 11092432 ecr 4265786729], length 0
09:58:35.898931 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60001: Flags [F.], seq 1, ack 182, win 235, options [nop,nop,TS val 11092432 ecr 4265786729], length 0
09:58:36.085155 IP 144.168.57.18.16clouds.com.60001 > 123.57.19.192.9000: Flags [.], ack 2, win 115, options [nop,nop,TS val 4265786918 ecr 11092432], length 0
09:58:36.085412 IP 144.168.57.18.16clouds.com.60001 > 123.57.19.192.9000: Flags [F.], seq 182, ack 2, win 115, options [nop,nop,TS val 4265786919 ecr 11092432], length 0
09:58:36.085428 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60001: Flags [.], ack 183, win 235, options [nop,nop,TS val 11092479 ecr 4265786919], length 0
09:58:36.448568 IP 144.168.57.18.16clouds.com.60042 > 123.57.19.192.9000: Flags [S], seq 2802058045, win 14600, options [mss 1460,sackOK,TS val 4265787278 ecr 0,nop,wscale 7], length 0
09:58:36.448612 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60042: Flags [S.], seq 3286643714, ack 2802058046, win 28960, options [mss 1460,sackOK,TS val 11092570 ecr 4265787278,nop,wscale 7], length 0
09:58:36.639745 IP 144.168.57.18.16clouds.com.60042 > 123.57.19.192.9000: Flags [.], ack 1, win 115, options [nop,nop,TS val 4265787468 ecr 11092570], length 0
09:58:36.639890 IP 144.168.57.18.16clouds.com.60042 > 123.57.19.192.9000: Flags [P.], seq 1:188, ack 1, win 115, options [nop,nop,TS val 4265787468 ecr 11092570], length 187
09:58:36.639909 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60042: Flags [.], ack 188, win 235, options [nop,nop,TS val 11092617 ecr 4265787468], length 0
09:58:36.639951 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60042: Flags [F.], seq 1, ack 188, win 235, options [nop,nop,TS val 11092617 ecr 4265787468], length 0
09:58:36.834075 IP 144.168.57.18.16clouds.com.60042 > 123.57.19.192.9000: Flags [.], ack 2, win 115, options [nop,nop,TS val 4265787659 ecr 11092617], length 0
09:58:36.834234 IP 144.168.57.18.16clouds.com.60042 > 123.57.19.192.9000: Flags [F.], seq 188, ack 2, win 115, options [nop,nop,TS val 4265787660 ecr 11092617], length 0
09:58:36.834251 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60042: Flags [.], ack 189, win 235, options [nop,nop,TS val 11092666 ecr 4265787660], length 0
09:58:37.223332 IP 144.168.57.18.16clouds.com.60098 > 123.57.19.192.9000: Flags [S], seq 2047347230, win 14600, options [mss 1460,sackOK,TS val 4265788046 ecr 0,nop,wscale 7], length 0
09:58:37.223378 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60098: Flags [S.], seq 37425333, ack 2047347231, win 28960, options [mss 1460,sackOK,TS val 11092763 ecr 4265788046,nop,wscale 7], length 0
09:58:37.418068 IP 144.168.57.18.16clouds.com.60098 > 123.57.19.192.9000: Flags [.], ack 1, win 115, options [nop,nop,TS val 4265788244 ecr 11092763], length 0
09:58:37.418703 IP 144.168.57.18.16clouds.com.60098 > 123.57.19.192.9000: Flags [P.], seq 1:148, ack 1, win 115, options [nop,nop,TS val 4265788245 ecr 11092763], length 147
09:58:37.418725 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60098: Flags [.], ack 148, win 235, options [nop,nop,TS val 11092812 ecr 4265788245], length 0
09:58:37.418762 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60098: Flags [F.], seq 1, ack 148, win 235, options [nop,nop,TS val 11092812 ecr 4265788245], length 0
09:58:37.612191 IP 144.168.57.18.16clouds.com.60098 > 123.57.19.192.9000: Flags [F.], seq 148, ack 2, win 115, options [nop,nop,TS val 4265788440 ecr 11092812], length 0
09:58:37.612215 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60098: Flags [.], ack 149, win 235, options [nop,nop,TS val 11092860 ecr 4265788440], length 0
09:58:37.970564 IP 144.168.57.18.16clouds.com.60157 > 123.57.19.192.9000: Flags [S], seq 298496264, win 14600, options [mss 1460,sackOK,TS val 4265788792 ecr 0,nop,wscale 7], length 0
09:58:37.970609 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60157: Flags [S.], seq 1330572639, ack 298496265, win 28960, options [mss 1460,sackOK,TS val 11092950 ecr 4265788792,nop,wscale 7], length 0
09:58:38.173099 IP 144.168.57.18.16clouds.com.60157 > 123.57.19.192.9000: Flags [.], ack 1, win 115, options [nop,nop,TS val 4265788991 ecr 11092950], length 0
09:58:38.173322 IP 144.168.57.18.16clouds.com.60157 > 123.57.19.192.9000: Flags [P.], seq 1:148, ack 1, win 115, options [nop,nop,TS val 4265788991 ecr 11092950], length 147
09:58:38.173343 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60157: Flags [.], ack 148, win 235, options [nop,nop,TS val 11093001 ecr 4265788991], length 0
09:58:38.173380 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60157: Flags [F.], seq 1, ack 148, win 235, options [nop,nop,TS val 11093001 ecr 4265788991], length 0
09:58:38.363877 IP 144.168.57.18.16clouds.com.60157 > 123.57.19.192.9000: Flags [.], ack 2, win 115, options [nop,nop,TS val 4265789194 ecr 11093001], length 0
09:58:38.363919 IP 144.168.57.18.16clouds.com.60157 > 123.57.19.192.9000: Flags [F.], seq 148, ack 2, win 115, options [nop,nop,TS val 4265789195 ecr 11093001], length 0
09:58:38.363936 IP 123.57.19.192.9000 > 144.168.57.18.16clouds.com.60157: Flags [.], ack 149, win 235, options [nop,nop,TS val 11093048 ecr 4265789195], length 0

And I used "videoroomtest" demo, and only changed
var server = "wss://" + window.location.hostname + ":9000/";
    
I guess the correct subprotocol must be passing.

在 2016年4月6日星期三 UTC+8下午7:10:16,Lorenzo Miniero写道:

Lorenzo Miniero

unread,
Apr 7, 2016, 7:15:27 AM4/7/16
to meetecho-janus
Please stop pasting all this text in the posts. As explained in the guidelines above, use a service like gist or pastebin next time.

L.

Chen Cong

unread,
Apr 7, 2016, 9:57:18 PM4/7/16
to meetecho-janus
I am very sorry. I did not read the guidelines.

I  use "tcpdump" to check TCP connection state, I am not very clear about how TCP works. 

I used command 
tcpdump -i any port 9000

and result

And I used "videoroomtest" demo, and only changed
var server = "wss://" + window.location.hostname + ":9000/";
    
I guess the correct subprotocol must be passing.




在 2016年4月7日星期四 UTC+8下午7:15:27,Lorenzo Miniero写道:

Lorenzo Miniero

unread,
Apr 8, 2016, 8:08:37 AM4/8/16
to meetecho-janus
Have you checked with different browsers? Have you tried if non-secure WebSockets work? Make also sure that port 9000 is open on the server, and it might help to setup a valid certificate for the WSS server as well (not sure if browsers accept a self signed certificate).

L.

Chen Cong

unread,
Apr 8, 2016, 8:34:05 AM4/8/16
to meetecho-janus
I have checked with Firefox and Chrome,and both can not connect to wss server.

It is no problem to connect non-secure WebSocket server.

I am sure the port 9000 is open.

My certificate was signed by "Let`s Encrypt",and browsers accept it well. I think there is no problem with my certificate.

the error log in browser is "ERR_CONNECTION_CLOSED", I think the wss server is accessible,but the connection closes immediately.

在 2016年4月8日星期五 UTC+8下午8:08:37,Lorenzo Miniero写道:

Lorenzo Miniero

unread,
Apr 8, 2016, 8:38:10 AM4/8/16
to meetecho-janus
I'm not very familiar with libwebsockets so not sure what may be going wrong there. If it keeps on not wotking, you might want to put a proxy/frontend that takes care of WSS and use simple WS in Janus itself, e.g., via HTTPD/nginx/others as explained here:


So that you can do something like:

    user <--- [WSS] ---> Proxy <--- [WS] ---> Janus

L.
Message has been deleted

Chen Cong

unread,
Apr 8, 2016, 8:58:36 AM4/8/16
to meetecho-janus
Thx for your reply.

I will try it. Thank you very much.

在 2016年4月8日星期五 UTC+8下午8:38:10,Lorenzo Miniero写道:
Reply all
Reply to author
Forward
0 new messages