Skip to content

Commit d84a81f

Browse files
committed
expose cowboy idle_timeout, fixes #10
1 parent b21886f commit d84a81f

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

README.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ The three callbacks receive the same arguments:
4444
* Username: username provided by the client executing the action.
4545
* OtherUsers: list of the rest of the usernames currently in the room.
4646

47+
### server configuration
48+
49+
* port: port used to serve the signaling server and the example client.
50+
* certfile: path to the certificate file for the signaling server and
51+
example client.
52+
* keyfile: path to the key file for the signaling server and
53+
example client.
54+
* hostname: name of the host where the app will be deployed. Will be
55+
used as the `auth_realm` for stun and to lookup the `turn_ip`
56+
* turn_ip: IP of the server where the app will be deployed. If not
57+
provided, will default to the first result of
58+
`inet_res:lookup(Hostname, in, a)`
59+
* idle_timeout: cowboy configuration for the websocket
60+
connections. By default will disconnect idle sockets after a
61+
minute (thus requiring the clients to periodically send a ping). Use
62+
`infinity` to prevent disconnections.
63+
4764
## Websockets API for signaling
4865

4966
TODO
@@ -52,28 +69,21 @@ TODO
5269

5370
make dev
5471

55-
The app will run on `https://localhost:8443/:room`
72+
The example app will run on `https://localhost:8443/:room`
5673

5774
## Run in production
5875

59-
### Configuration
60-
Update the configuration in `conf/sys.config`:
61-
62-
* port: set to 443 for HTTPS.
63-
* certfile: absolute path to the certificate file.
64-
* keyfile: absolute path to the key file.
65-
* hostname: name of the host where the app will be deployed. Will be
66-
used as the `auth_realm` for stun and to lookup the `turn_ip`
67-
* turn_ip: IP of the server where the app will be deployed. If not
68-
provided, will default to the first result of
69-
`inet_res:lookup(Hostname, in, a)`
70-
71-
### Build a release
76+
To run the example app stand alone in a production server, update the
77+
relevant configuration in `conf/sys.config` (port, certs, host, etc.)
78+
and run:
7279

7380
make release
7481

7582
Unpack the generated tar and `bin/webrtc_server start`.
7683

84+
Alternatively, the webrtc_server application can be included as a
85+
dependency in another project.
86+
7787
### Firewall setup for STUN/TURN
7888

7989
```

src/webrtc_ws_handler.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
init(Req, _) ->
1111
Room = cowboy_req:binding(room, Req),
12-
{cowboy_websocket, Req, #{room => Room, authenticated => false}}.
12+
IdleTimeout = application:get_env(webrtc_server, idle_timeout, 60000),
13+
{cowboy_websocket, Req,
14+
#{room => Room, authenticated => false},
15+
#{idle_timeout => IdleTimeout}}.
1316

1417
websocket_init(State) ->
1518
Time = application:get_env(webrtc_server, ws_auth_delay, 300),

0 commit comments

Comments
 (0)