Websockets

Hi,

I am playing with websocketson Asterisk 11.5.0. I can connect over Http to the manager and standard TCP. I have make the config changes suggested here https://wiki.asterisk.org/wiki/display/AST/Asterisk+WebRTC+Support

curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: localhost" -H "Origin: http://localhost:8088" http://localhost:8088/ws

And get the response …

HTTP/1.1 400 Bad Request Sec-WebSocket-Version: 7, 8, 13

Has anyone got any suggestion of things to try ?

Enable logging.

David,

The only reference to logging I can find is in the manager.conf, however the comments read

; log - Logging information. Read-only. (Defined but not yet used.)

Where and how would I enable logging for the webserver ?

I can see a warning when running asterisk -vvvvvv -g -dddddd -c

That

Any idea how to specify the protocol ?

I changed the curl slightly as follows and got the following response

 curl -v http://127.0.0.1:8088/ws -H "Upgrade: WebSocket" -H "Connection: Upgrade" -H "Origin: http://localhost"
* About to connect() to 127.0.0.1 port 8088 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8088 (#0)
> GET /ws HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:8088
> Accept: */*
> Upgrade: WebSocket
> Connection: Upgrade
> Origin: http://localhost
>
< HTTP/1.1 400 Bad Request
< Sec-WebSocket-Version: 7, 8, 13
* no chunk, no close, no size. Assume close to signal end
<
* Closing connection 0

logger.conf, CLI core set verbose, core set debug, and set debug

David,

Thanks, I could see that the protocol was not supported. So I made an obvious change

adding in

So the full Curl command becomes :

curl -v http://127.0.0.1:8088/ws -H "Upgrade: WebSocket" -H "Connection: Upgrade" -H "Sec-WebSocket-Version: 7" -H "Sec-WebSocket-Protocol: sip" -H "Origin: http://localhost"

and now I get a more reasonable response

[code]* About to connect() to 127.0.0.1 port 8088 (#0)

  • Trying 127.0.0.1…
  • Connected to 127.0.0.1 (127.0.0.1) port 8088 (#0)

GET /ws HTTP/1.1
User-Agent: curl/7.29.0
Host: 127.0.0.1:8088
Accept: /
Upgrade: WebSocket
Connection: Upgrade
Sec-WebSocket-Version: 7
Sec-WebSocket-Protocol: sip
Origin: http://localhost

  • Empty reply from server
  • Connection #0 to host 127.0.0.1 left intact
    curl: (52) Empty reply from server
    [/code]