Summary:ASTERISK-21930: [patch]WebRTC over WSS is not working.
Reporter:John (tilt)Labels:
Date Opened:2013-06-19 22:22:05Date Closed:2014-03-11 14:38:00
Versions:11.4.0 Frequency of
duplicatesASTERISK-23190 WebRTC (WSS + TLS) No Audio
is related toASTERISK-23099 [patch] WSS: enable ast_websocket_read() function to read the whole available data at first and then wait for any fragmented packets
Environment:debian wheezy, asterisk 11.4, sipml5-webphoneAttachments:( 0) asterisk_debug_log
( 1) webrtc-trunk.patch
Description:Websocket connection over secure WSS gives a the following:

== WebSocket connection from '' for protocol 'sip' accepted using version '13'

but peer will never register.

Using the unsecure WS, everything works as expected.
Comments:By: JoshE (n8ideas) 2013-06-20 23:18:15.121-0500

Can confirm same behavior with WSS.

By: Matt Jordan (mjordan) 2013-07-01 12:42:05.581-0500

We require a complete debug log to help triage the issue. This document will provide instructions on how to collect debugging logs from an Asterisk machine for the purpose of helping bug marshals troubleshoot an issue: https://wiki.asterisk.org/wiki/display/AST/Collecting+Debug+Information

By: Matt Jordan (mjordan) 2013-07-01 12:42:42.951-0500

Please also attach your full sip.conf and extensions.conf to this issue. When you provide the log, please make sure that 'sip set debug on' is enabled, and indicate which peer was attempting to register.

By: Rusty Newton (rnewton) 2013-07-16 16:39:19.681-0500

Suspended due to lack of activity. Please request a bug marshal in #asterisk-bugs on the IRC network irc.freenode.net to reopen the issue should you have the additional information requested.  Further information can be found at http://www.asterisk.org/developers/bug-guidelines

By: Moises Silva (moy) 2013-10-09 13:00:20.495-0500

I think this is still an issue.

I have a branch where I propose a fix:


I'll update to Asterisk 12 and trunk soon

By: Moises Silva (moy) 2013-10-09 22:31:17.864-0500

Another little nugget of information ...

It seems with Asterisk 11 branch I have no audio (even without my patch, so is not related). Using standard Asterisk 11.5.1 I have audio (using sipml SIP stack). From chrome://webrtc-internals for some reason there is no packets sent when connecting to Asterisk 11 branch (revision 400821) ... I have not checked the code differences yet between 11.5.1 and revision 400821

By: Moises Silva (moy) 2013-10-11 01:22:52.324-0500

I have webrtc-12 and webrtc-trunk branches now as well


Find the patch for trunk attached as well if you find that easier to review.

The patch includes:

Several fixes for the WebSockets implementation in res/res_http_websocket.c

* Flush the websocket session FILE* as fwrite() may not actually guarantee sending
 the data to the network. If we do not flush, it seems that buffering on the SSL
 socket for outbound messages causes issues

* Refactored ast_websocket_read to take into account that SSL file descriptors
 may be ready to read via fread() but poll() will not actually say so because
 the data was already read from the network buffers and is now in the libc buffers

This should fix an issue that I have experienced and other users may have reported [1][2], where
secure websockets wouldn't work, messages seem to not make it into Asterisk

[1] http://lists.digium.com/pipermail/asterisk-users/2013-August/280175.html
[2] ASTERISK-21930

By: Moises Silva (moy) 2013-10-11 03:13:20.314-0500

Oh boy ... the audio issue was caused by missing the pjproject dependency. It's puzzling no warning at all or error is printed on Asterisk when using WebRTC and pjproject is not present. I am not sure however exactly where in the code (or during build) this warning/error should be printed.

I guess chan_sip could check if ws/wss transport is registered and no pjsip (HAVE_PJPROJECT) is built, then print a nasty error and abort the call?

By: Moises Silva (moy) 2013-10-11 03:13:41.824-0500

Btw, I've updated the Asterisk WebRTC page to indicate the pjproject requirement

By: Tim Somers (somerst) 2013-10-16 04:30:10.450-0500

I tried you patches today, both the exact version you posted and based on the latest trunk. The client registers fine, but when trying to make a call, I get only a single line in rasterisk:
[Oct 16 11:23:48] ERROR[29347]: res_http_websocket.c:455 __ast_websocket_read: Error reading from web socket!
Both sip and core debug are on, but nothing gets logged. The sipml5 clients get stuck on "Call in progress...".
Clients are Chrome 32.0.1664.3 on debian, chrome 30.0.1599.69 on windows, firefox nightly 27.0a1 on windows, with the latest sipml5 code. All give the exact same result.

Is there any way I can get you more info to get this working?

By: Moises Silva (moy) 2013-10-16 09:24:46.082-0500

If I can get ssh (we can sync up on Skype: moy.silva) that would help move things faster instead of going back and forth here trying different things.

Are you the original reporter? are you using wss as the transport?

I usually prefer launching "asterisk -vvvvvvvvc" when debugging instead of using rasterisk. Make sure you have the correct debugging console line in /etc/asterisk/logger.conf and upload a full debugging log of the whole sequence (registration, call attempt)

By: Tim Somers (somerst) 2013-10-17 02:58:48.812-0500

No, I'm not the original reporter, I just ran into the same problem.

I'm using wss transport indeed. If I try ws transport, I run into the "cannot get local sdp" problem, which is the same issue as when using a webrtc2sip proxy over ws instead of wss.

I ran asterisk with the command you specified, and attached its output to this ticket. Unfortunately, I don't see any more output than what I already posted.

By: Moises Silva (moy) 2013-10-21 01:40:12.436-0500

I've added a fix to all branches to solve the error Tim was facing (error reading from web socket).

I've confirmed in Tim's box the issue is solved. Now he is facing another problem pointing to his stun server, not sure yet, we'll continue debugging later, but at least the websocket connection is solid now, the issue lies now somewhere in SDP/ICE/STUN bootstraping ...

By: Tim Somers (somerst) 2013-11-13 10:56:20.710-0600

wss is now working for me. Both audio and video are fine.
I'm still getting the 'cannot get local sdp' error on incoming calls while outgoing calls work fine, but I do not believe this has anything to do with this ticket.

By: Rusty Newton (rnewton) 2013-12-12 16:58:37.680-0600

Thanks for all the work guys. If the primary issue of this ticket was fixed, we should close it out. Do you want to open a new ticket to track the secondary/tertiary issue?

By: Moises Silva (moy) 2013-12-12 17:29:54.585-0600

Hi Rusty,

Well, it's solved using my branch (see my previous comments for URL), so I don't think this can be closed until my branch is reviewed and merged by the Asterisk devs. This is the first time some of the Asterisk devs comment here, should I be creating a review request? I'm not sure what process to follow for this.

By: Jay Jideliov (jideliov) 2014-01-17 16:43:11.583-0600


Did you create the ticket for the secondary issue? Can't seem to locate it, and don't want to create duplicates.

By: Sean Bright (seanbright) 2014-01-20 16:20:57.532-0600

I can confirm that Moises' patch fixes WebRTC over WSS on Asterisk 11 as well.

By: Jay Jideliov (jideliov) 2014-01-27 17:09:16.313-0600

Were you able to get sound working over wss?

We started with this to enable srtp: ASTERISK-22961
Then we patched asterisk with Moises' patch.

However, we still cannot get sound to work. Please let me know if you are experiencing the same issue, and I will create a separate ticket.

By: Moises Silva (moy) 2014-01-28 15:32:30.766-0600

Yes audio works. Just make sure you've got pjproject installed, as newer versions of Asterisk (starting with Asterisk 12) require pjproject installed separately in order to use ICE functionality (does not come with Asterisk). See this: https://wiki.asterisk.org/wiki/display/AST/Installing+pjproject

Particularly, this note: Unlike Asterisk 11, which uses an embedded pjproject for the ICE, STUN and TURN libraries in its RTP engine for WebSockets support, Asterisk 12 dynamically links to pjproject.

By: Rusty Newton (rnewton) 2014-02-04 08:50:52.914-0600

bq. Well, it's solved using my branch (see my previous comments for URL), so I don't think this can be closed until my branch is reviewed and merged by the Asterisk devs. This is the first time some of the Asterisk devs comment here, should I be creating a review request? I'm not sure what process to follow for this.

If you are not on reviewboard, then you should just shoot an E-mail to the asterisk-dev list and ask for reviews on your branch.

Also it looks like Thava had some code with a similar purpose at ASTERISK-23099, you might also collaborate with Thava.

By: Moises Silva (moy) 2014-02-04 10:47:47.460-0600

I would say ASTERISK-23099 is a duplicate of this issue. This issue was created first by 'John' on Jun 13, 2013 and then re-open by me on Oct 09, 2013, when I found the same issue (instead of creating a new one).

I'll reach out to Thava and see what he thinks of my patch/branches and review his patch, then see if we can merge them if needed. From a quick look his patch looks like a subset from my patch.

I'll also submit a reviewboard request (I have a user on reviewboard already)

By: Moises Silva (moy) 2014-02-22 14:13:30.291-0600

Review Request: https://reviewboard.asterisk.org/r/3248/