Browse code

modules: readme files regenerated - websocket ... [skip ci]

Kamailio Dev authored on 21/06/2021 07:46:15
Showing 1 changed files
... ...
@@ -162,6 +162,8 @@ Chapter 1. Admin Guide
162 162
 
163 163
    Example 1.1. event_route[xhttp:request]
164 164
 ...
165
+tcp_accept_no_cl=yes
166
+...
165 167
 loadmodule "sl.so"
166 168
 loadmodule "xhttp.so"
167 169
 loadmodule "msrp.so"  # Only required if using MSRP over WebSockets
Browse code

modules: readme files regenerated - carrierroute ... [skip ci]

Kamailio Dev authored on 02/10/2020 14:01:15
Showing 1 changed files
... ...
@@ -672,8 +672,8 @@ kamcmd ws.enable
672 672
 7.1.  websocket:closed
673 673
 
674 674
    When defined, the module calls event_route[websocket:closed] when a
675
-   connection closes. The connection may be identified using the the $si
676
-   and $sp pseudo-variables.
675
+   connection closes. The connection may be identified using the $si and
676
+   $sp pseudo-variables.
677 677
 
678 678
    Example 1.16. event_route[websocket:closed] usage
679 679
 ...
Browse code

modules: readme files regenerated - acc_json ... [skip ci]

Kamailio Dev authored on 04/03/2020 09:46:17
Showing 1 changed files
... ...
@@ -73,7 +73,7 @@ Peter Dunkley
73 73
    1.10. Set verbose_list parameter
74 74
    1.11. Set event_callback parameter
75 75
    1.12. Set timer_intervalparameter
76
-   1.13. Set rm_timer_intervalparameter
76
+   1.13. Set rm_delay_intervalparameter
77 77
    1.14. ws_handle_handshake usage
78 78
    1.15. ws_close usage
79 79
    1.16. event_route[websocket:closed] usage
... ...
@@ -511,7 +511,7 @@ modparam("websocket", "timer_interval", 5)
511 511
 
512 512
    Default value is 5.
513 513
 
514
-   Example 1.13. Set rm_timer_intervalparameter
514
+   Example 1.13. Set rm_delay_intervalparameter
515 515
 ...
516 516
 modparam("websocket", "rm_delay_interval", 2)
517 517
 ...
Browse code

modules: readme files regenerated - websocket ... [skip ci]

Kamailio Dev authored on 09/10/2019 20:46:11
Showing 1 changed files
... ...
@@ -427,9 +427,11 @@ modparam("websocket", "ping_application_data", "WebSockets rock")
427 427
    A bitmap that allows you to control the sub-protocols supported by the
428 428
    WebSocket server.
429 429
      * 1 - sip (RFC 7118)
430
-     * 2 - msrp (RFC 7977) - msrp.so must be loaded before websocket.so
430
+     * 2 - msrp (RFC 7977) - the msrp module must be loaded before the
431
+       websocket module
431 432
 
432
-   Default value is 1 when msrp.so is not loaded 3 when msrp.so is loaded.
433
+   Default value is 1 when msrp module is not loaded, 3 when msrp module
434
+   is loaded.
433 435
 
434 436
    Example 1.8. Set sub_protocols parameter
435 437
 ...
Browse code

modules: readme files regenerated - websocket ... [skip ci]

Kamailio Dev authored on 19/12/2018 13:16:41
Showing 1 changed files
... ...
@@ -34,6 +34,8 @@ Peter Dunkley
34 34
               4.7. cors_mode (integer)
35 35
               4.8. verbose_list (int)
36 36
               4.9. event_callback (str)
37
+              4.10. timer_interval (integer)
38
+              4.11. rm_delay_interval (integer)
37 39
 
38 40
         5. Functions
39 41
 
... ...
@@ -70,10 +72,12 @@ Peter Dunkley
70 72
    1.9. Set cors_mode parameter
71 73
    1.10. Set verbose_list parameter
72 74
    1.11. Set event_callback parameter
73
-   1.12. ws_handle_handshake usage
74
-   1.13. ws_close usage
75
-   1.14. event_route[websocket:closed] usage
76
-   1.15. $ws_conid usage
75
+   1.12. Set timer_intervalparameter
76
+   1.13. Set rm_timer_intervalparameter
77
+   1.14. ws_handle_handshake usage
78
+   1.15. ws_close usage
79
+   1.16. event_route[websocket:closed] usage
80
+   1.17. $ws_conid usage
77 81
 
78 82
 Chapter 1. Admin Guide
79 83
 
... ...
@@ -102,6 +106,8 @@ Chapter 1. Admin Guide
102 106
         4.7. cors_mode (integer)
103 107
         4.8. verbose_list (int)
104 108
         4.9. event_callback (str)
109
+        4.10. timer_interval (integer)
110
+        4.11. rm_delay_interval (integer)
105 111
 
106 112
    5. Functions
107 113
 
... ...
@@ -345,6 +351,8 @@ onreply_route[WS_REPLY] {
345 351
    4.7. cors_mode (integer)
346 352
    4.8. verbose_list (int)
347 353
    4.9. event_callback (str)
354
+   4.10. timer_interval (integer)
355
+   4.11. rm_delay_interval (integer)
348 356
 
349 357
 4.1. keepalive_mechanism (integer)
350 358
 
... ...
@@ -483,6 +491,29 @@ function ksr_websocket_event(evname)
483 491
 end
484 492
 ...
485 493
 
494
+4.10. timer_interval (integer)
495
+
496
+   The number of seconds between each timer process run
497
+
498
+   Default value is 1.
499
+
500
+   Example 1.12. Set timer_intervalparameter
501
+...
502
+modparam("websocket", "timer_interval", 5)
503
+...
504
+
505
+4.11. rm_delay_interval (integer)
506
+
507
+   The number of seconds to wait before destroying the websocket
508
+   connection once put in remove state.
509
+
510
+   Default value is 5.
511
+
512
+   Example 1.13. Set rm_timer_intervalparameter
513
+...
514
+modparam("websocket", "rm_delay_interval", 2)
515
+...
516
+
486 517
 5. Functions
487 518
 
488 519
    5.1. ws_handle_handshake()
... ...
@@ -503,7 +534,7 @@ Note
503 534
    request, when there is a problem. Otherwise, it returns 1 (or positive
504 535
    number) in case of success.
505 536
 
506
-   Example 1.12. ws_handle_handshake usage
537
+   Example 1.14. ws_handle_handshake usage
507 538
 ...
508 539
 ws_handle_handshake();
509 540
 ...
... ...
@@ -528,7 +559,7 @@ Note
528 559
 
529 560
    This function can be used from ANY_ROUTE.
530 561
 
531
-   Example 1.13. ws_close usage
562
+   Example 1.15. ws_close usage
532 563
 ...
533 564
 ws_close(4000, "Because I say so");
534 565
 ...
... ...
@@ -642,7 +673,7 @@ kamcmd ws.enable
642 673
    connection closes. The connection may be identified using the the $si
643 674
    and $sp pseudo-variables.
644 675
 
645
-   Example 1.14. event_route[websocket:closed] usage
676
+   Example 1.16. event_route[websocket:closed] usage
646 677
 ...
647 678
 event_route[websocket:closed] {
648 679
         xlog("L_INFO", "WebSocket connection from $si:$sp has closed\n");
... ...
@@ -658,7 +689,7 @@ event_route[websocket:closed] {
658 689
    Connection id of closed websocket connection. Can only be used in
659 690
    websocket:closed event route.
660 691
 
661
-   Example 1.15. $ws_conid usage
692
+   Example 1.17. $ws_conid usage
662 693
 ...
663 694
 event_route[websocket:closed] {
664 695
         xlog("L_INFO", "WebSocket connection with id $ws_conid has closed\n");
Browse code

modules: readme files regenerated - dialog ... [skip ci]

Kamailio Dev authored on 06/12/2018 08:52:16
Showing 1 changed files
... ...
@@ -203,7 +203,7 @@ event_route[xhttp:request] {
203 203
                 # Optional... perform HTTP authentication
204 204
 
205 205
                 # ws_handle_handshake() exits (no further configuration file
206
-                # processing of the request) when complete.
206
+                # processing of the request) when complete in case of failure.
207 207
                 if (ws_handle_handshake())
208 208
                 {
209 209
                         # Optional... cache some information about the
... ...
@@ -500,7 +500,8 @@ end
500 500
 Note
501 501
 
502 502
    This function returns 0, stopping all further processing of the
503
-   request, when there is a problem.
503
+   request, when there is a problem. Otherwise, it returns 1 (or positive
504
+   number) in case of success.
504 505
 
505 506
    Example 1.12. ws_handle_handshake usage
506 507
 ...
Browse code

modules: readme files regenerated - websocket ... [skip ci]

Kamailio Dev authored on 04/08/2017 13:16:23
Showing 1 changed files
... ...
@@ -33,6 +33,7 @@ Peter Dunkley
33 33
               4.6. sub_protocols (integer)
34 34
               4.7. cors_mode (integer)
35 35
               4.8. verbose_list (int)
36
+              4.9. event_callback (str)
36 37
 
37 38
         5. Functions
38 39
 
... ...
@@ -68,10 +69,11 @@ Peter Dunkley
68 69
    1.8. Set sub_protocols parameter
69 70
    1.9. Set cors_mode parameter
70 71
    1.10. Set verbose_list parameter
71
-   1.11. ws_handle_handshake usage
72
-   1.12. ws_close usage
73
-   1.13. event_route[websocket:closed] usage
74
-   1.14. $ws_conid usage
72
+   1.11. Set event_callback parameter
73
+   1.12. ws_handle_handshake usage
74
+   1.13. ws_close usage
75
+   1.14. event_route[websocket:closed] usage
76
+   1.15. $ws_conid usage
75 77
 
76 78
 Chapter 1. Admin Guide
77 79
 
... ...
@@ -99,6 +101,7 @@ Chapter 1. Admin Guide
99 101
         4.6. sub_protocols (integer)
100 102
         4.7. cors_mode (integer)
101 103
         4.8. verbose_list (int)
104
+        4.9. event_callback (str)
102 105
 
103 106
    5. Functions
104 107
 
... ...
@@ -341,6 +344,7 @@ onreply_route[WS_REPLY] {
341 344
    4.6. sub_protocols (integer)
342 345
    4.7. cors_mode (integer)
343 346
    4.8. verbose_list (int)
347
+   4.9. event_callback (str)
344 348
 
345 349
 4.1. keepalive_mechanism (integer)
346 350
 
... ...
@@ -457,6 +461,28 @@ modparam("websocket", "cors_mode", 2)
457 461
 modparam("websocket", "verbose_list", 1)
458 462
 ...
459 463
 
464
+4.9. event_callback (str)
465
+
466
+   The name of the function in the kemi configuration file (embedded
467
+   scripting language such as Lua, Python, ...) to be executed instead of
468
+   event_route[...] blocks specific for websocket module.
469
+
470
+   The function has one string parameter, the value is the name of the
471
+   event_route block, respectively "websocket:closed".
472
+
473
+   Default value is 'empty' (no function is executed for events).
474
+
475
+   Example 1.11. Set event_callback parameter
476
+...
477
+modparam("websocket", "event_callback", "ksr_websocket_event")
478
+...
479
+-- event callback function implemented in Lua
480
+function ksr_websocket_event(evname)
481
+        KSR.info("===== websocket module triggered event: " .. evname .. "\n");
482
+        return 1;
483
+end
484
+...
485
+
460 486
 5. Functions
461 487
 
462 488
    5.1. ws_handle_handshake()
... ...
@@ -476,7 +502,7 @@ Note
476 502
    This function returns 0, stopping all further processing of the
477 503
    request, when there is a problem.
478 504
 
479
-   Example 1.11. ws_handle_handshake usage
505
+   Example 1.12. ws_handle_handshake usage
480 506
 ...
481 507
 ws_handle_handshake();
482 508
 ...
... ...
@@ -501,7 +527,7 @@ Note
501 527
 
502 528
    This function can be used from ANY_ROUTE.
503 529
 
504
-   Example 1.12. ws_close usage
530
+   Example 1.13. ws_close usage
505 531
 ...
506 532
 ws_close(4000, "Because I say so");
507 533
 ...
... ...
@@ -615,7 +641,7 @@ kamcmd ws.enable
615 641
    connection closes. The connection may be identified using the the $si
616 642
    and $sp pseudo-variables.
617 643
 
618
-   Example 1.13. event_route[websocket:closed] usage
644
+   Example 1.14. event_route[websocket:closed] usage
619 645
 ...
620 646
 event_route[websocket:closed] {
621 647
         xlog("L_INFO", "WebSocket connection from $si:$sp has closed\n");
... ...
@@ -631,7 +657,7 @@ event_route[websocket:closed] {
631 657
    Connection id of closed websocket connection. Can only be used in
632 658
    websocket:closed event route.
633 659
 
634
-   Example 1.14. $ws_conid usage
660
+   Example 1.15. $ws_conid usage
635 661
 ...
636 662
 event_route[websocket:closed] {
637 663
         xlog("L_INFO", "WebSocket connection with id $ws_conid has closed\n");
Browse code

modules: readme files regenerated - websocket ...

Kamailio Dev authored on 31/01/2017 11:31:15
Showing 1 changed files
... ...
@@ -32,6 +32,7 @@ Peter Dunkley
32 32
               4.5. ping_application_data (string)
33 33
               4.6. sub_protocols (integer)
34 34
               4.7. cors_mode (integer)
35
+              4.8. verbose_list (int)
35 36
 
36 37
         5. Functions
37 38
 
... ...
@@ -66,10 +67,11 @@ Peter Dunkley
66 67
    1.7. Set ping_application_data parameter
67 68
    1.8. Set sub_protocols parameter
68 69
    1.9. Set cors_mode parameter
69
-   1.10. ws_handle_handshake usage
70
-   1.11. ws_close usage
71
-   1.12. event_route[websocket:closed] usage
72
-   1.13. $ws_conid usage
70
+   1.10. Set verbose_list parameter
71
+   1.11. ws_handle_handshake usage
72
+   1.12. ws_close usage
73
+   1.13. event_route[websocket:closed] usage
74
+   1.14. $ws_conid usage
73 75
 
74 76
 Chapter 1. Admin Guide
75 77
 
... ...
@@ -96,6 +98,7 @@ Chapter 1. Admin Guide
96 98
         4.5. ping_application_data (string)
97 99
         4.6. sub_protocols (integer)
98 100
         4.7. cors_mode (integer)
101
+        4.8. verbose_list (int)
99 102
 
100 103
    5. Functions
101 104
 
... ...
@@ -337,6 +340,7 @@ onreply_route[WS_REPLY] {
337 340
    4.5. ping_application_data (string)
338 341
    4.6. sub_protocols (integer)
339 342
    4.7. cors_mode (integer)
343
+   4.8. verbose_list (int)
340 344
 
341 345
 4.1. keepalive_mechanism (integer)
342 346
 
... ...
@@ -440,6 +444,19 @@ modparam("websocket", "sub_protocols", 2)
440 444
 modparam("websocket", "cors_mode", 2)
441 445
 ...
442 446
 
447
+4.8. verbose_list (int)
448
+
449
+   Allows to enable/disable the printing of debug messages when getting
450
+   the list of websocket connections. If enabled, it prints debug messages
451
+   every second for ping operations.
452
+
453
+   Default value is 0 (disabled).
454
+
455
+   Example 1.10. Set verbose_list parameter
456
+...
457
+modparam("websocket", "verbose_list", 1)
458
+...
459
+
443 460
 5. Functions
444 461
 
445 462
    5.1. ws_handle_handshake()
... ...
@@ -459,7 +476,7 @@ Note
459 476
    This function returns 0, stopping all further processing of the
460 477
    request, when there is a problem.
461 478
 
462
-   Example 1.10. ws_handle_handshake usage
479
+   Example 1.11. ws_handle_handshake usage
463 480
 ...
464 481
 ws_handle_handshake();
465 482
 ...
... ...
@@ -484,7 +501,7 @@ Note
484 501
 
485 502
    This function can be used from ANY_ROUTE.
486 503
 
487
-   Example 1.11. ws_close usage
504
+   Example 1.12. ws_close usage
488 505
 ...
489 506
 ws_close(4000, "Because I say so");
490 507
 ...
... ...
@@ -598,7 +615,7 @@ kamcmd ws.enable
598 615
    connection closes. The connection may be identified using the the $si
599 616
    and $sp pseudo-variables.
600 617
 
601
-   Example 1.12. event_route[websocket:closed] usage
618
+   Example 1.13. event_route[websocket:closed] usage
602 619
 ...
603 620
 event_route[websocket:closed] {
604 621
         xlog("L_INFO", "WebSocket connection from $si:$sp has closed\n");
... ...
@@ -614,7 +631,7 @@ event_route[websocket:closed] {
614 631
    Connection id of closed websocket connection. Can only be used in
615 632
    websocket:closed event route.
616 633
 
617
-   Example 1.13. $ws_conid usage
634
+   Example 1.14. $ws_conid usage
618 635
 ...
619 636
 event_route[websocket:closed] {
620 637
         xlog("L_INFO", "WebSocket connection with id $ws_conid has closed\n");
Browse code

modules: readme files regenerated - acc ...

Kamailio Dev authored on 02/01/2017 16:31:15
Showing 1 changed files
... ...
@@ -124,10 +124,10 @@ Chapter 1. Admin Guide
124 124
    This module implements a WebSocket (RFC 6455) server and provides
125 125
    connection establishment (handshaking), management (including
126 126
    connection keep-alive), and framing for the SIP and MSRP WebSocket
127
-   sub-protocols (draft-ietf-sipcore-sip-websocket and
128
-   draft-pd-msrp-websocket).
127
+   sub-protocols (RFC 7118 and RFC 7977).
129 128
 
130 129
    The module supports WebSockets (ws) and secure WebSockets (wss)
130
+   transports
131 131
 
132 132
 2. How it works
133 133
 
... ...
@@ -218,11 +218,11 @@ event_route[xhttp:request] {
218 218
    WebSocket connection is made. This means that the routing headers
219 219
    cannot be used for request or response routing in the normal manner.
220 220
 
221
-   draft-ietf-sipcore-sip-websocket states that SIP WebSocket Clients and
222
-   the SIP registrar should implement Outbound (RFC 5626) and Path (RFC
223
-   3327) to enable requests and responses to be correctly routed. However,
224
-   Kamailio does not currently support Outbound and it may not be possible
225
-   to guarantee all SIP WebSocket clients will support Outbound and Path.
221
+   RFC 7118 - The WebSocket Protocol as a Transport for the Session
222
+   Initiation Protocol - states that SIP WebSocket Clients and the SIP
223
+   registrar should implement SIP Outbound (RFC 5626) and Path header
224
+   support (RFC 3327) to enable requests and responses to be correctly
225
+   routed. Kamailio has a module called "Outbound" for this functionality.
226 226
 
227 227
    The nathelper module functions (nat_uac_test(), fix_nated_register(),
228 228
    add_contact_alias(), and handle_ruri_alias()) and the Kamailio core
... ...
@@ -386,7 +386,7 @@ modparam("websocket", "keepalive_processes", 2)
386 386
 
387 387
 4.4. keepalive_interval (integer)
388 388
 
389
-   The number of seconds between each keep-alice process run
389
+   The number of seconds between each keep-alive process run
390 390
 
391 391
    Default value is 1.
392 392
 
... ...
@@ -410,9 +410,8 @@ modparam("websocket", "ping_application_data", "WebSockets rock")
410 410
 
411 411
    A bitmap that allows you to control the sub-protocols supported by the
412 412
    WebSocket server.
413
-     * 1 - sip (draft-ietf-sipcore-sip-websocket)
414
-     * 2 - msrp (draft-pd-msrp-websocket) - msrp.so must be loaded before
415
-       websocket.so
413
+     * 1 - sip (RFC 7118)
414
+     * 2 - msrp (RFC 7977) - msrp.so must be loaded before websocket.so
416 415
 
417 416
    Default value is 1 when msrp.so is not loaded 3 when msrp.so is loaded.
418 417
 
Browse code

modules: readme files regenerated - matrix ...

Kamailio Dev authored on 24/12/2016 09:31:18
Showing 1 changed files
... ...
@@ -38,7 +38,7 @@ Peter Dunkley
38 38
               5.1. ws_handle_handshake()
39 39
               5.2. ws_close([status, reason[, connection_id]])
40 40
 
41
-        6. MI Commands
41
+        6. RPC Commands
42 42
 
43 43
               6.1. ws.dump
44 44
               6.2. ws.close
... ...
@@ -102,7 +102,7 @@ Chapter 1. Admin Guide
102 102
         5.1. ws_handle_handshake()
103 103
         5.2. ws_close([status, reason[, connection_id]])
104 104
 
105
-   6. MI Commands
105
+   6. RPC Commands
106 106
 
107 107
         6.1. ws.dump
108 108
         6.2. ws.close
... ...
@@ -490,7 +490,7 @@ Note
490 490
 ws_close(4000, "Because I say so");
491 491
 ...
492 492
 
493
-6. MI Commands
493
+6. RPC Commands
494 494
 
495 495
    6.1. ws.dump
496 496
    6.2. ws.close
... ...
@@ -512,10 +512,10 @@ Note
512 512
 
513 513
    If no parameter is provided id_hash order is used.
514 514
 
515
-   MI FIFO Command Format:
516
-                        :ws.dump:fifo_reply
517
-                        used_asc
518
-                        _empty_line_
515
+   RPC Command Usage:
516
+...
517
+kamcmd ws.dump used_asc
518
+...
519 519
 
520 520
 6.2. ws.close
521 521
 
... ...
@@ -526,10 +526,10 @@ Note
526 526
    Parameters:
527 527
      * id - WebSocket connection ID.
528 528
 
529
-   MI FIFO Command Format:
530
-                        :ws.close:fifo_reply
531
-                        1
532
-                        _empty_line_
529
+   RPC Command Usage:
530
+...
531
+kamcmd ws.close: 1
532
+...
533 533
 
534 534
 6.3. ws.ping
535 535
 
... ...
@@ -540,10 +540,10 @@ Note
540 540
    Parameters:
541 541
      * id - WebSocket connection ID.
542 542
 
543
-   MI FIFO Command Format:
544
-                        :ws.ping:fifo_reply
545
-                        1
546
-                        _empty_line_
543
+   RPC Command Usage:
544
+...
545
+kamcmd ws.ping 1
546
+...
547 547
 
548 548
 6.4. ws.pong
549 549
 
... ...
@@ -554,10 +554,10 @@ Note
554 554
    Parameters:
555 555
      * id - WebSocket connection ID.
556 556
 
557
-   MI FIFO Command Format:
558
-                        :ws.pong:fifo_reply
559
-                        1
560
-                        _empty_line_
557
+   RPC Command Usage:
558
+...
559
+kamcmd ws.pong 1
560
+...
561 561
 
562 562
 6.5. ws.disable
563 563
 
... ...
@@ -567,9 +567,10 @@ Note
567 567
 
568 568
    Parameters: none
569 569
 
570
-   MI FIFO Command Format:
571
-                        :ws.disable:fifo_reply
572
-                        _empty_line_
570
+   RPC Command Usage:
571
+...
572
+kamcmd ws.disable
573
+...
573 574
 
574 575
 6.6. ws.enable
575 576
 
... ...
@@ -583,9 +584,10 @@ Note
583 584
 
584 585
    Parameters: none
585 586
 
586
-   MI FIFO Command Format:
587
-                        :ws.enable:fifo_reply
588
-                        _empty_line_
587
+   RPC Command Format:
588
+...
589
+kamcmd ws.enable
590
+...
589 591
 
590 592
 7. Event routes
591 593
 
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,621 @@
1
+WebSocket Module
2
+
3
+Peter Dunkley
4
+
5
+   Crocodile RCS Ltd
6
+
7
+   Copyright © 2012-2013 Crocodile RCS Ltd
8
+     __________________________________________________________________
9
+
10
+   Table of Contents
11
+
12
+   1. Admin Guide
13
+
14
+        1. Overview
15
+        2. How it works
16
+
17
+              2.1. Initiating a connection
18
+              2.2. SIP message routing
19
+              2.3. MSRP message routing
20
+
21
+        3. Dependencies
22
+
23
+              3.1. Kamailio Modules
24
+              3.2. External Libraries or Applications
25
+
26
+        4. Parameters
27
+
28
+              4.1. keepalive_mechanism (integer)
29
+              4.2. keepalive_timeout (integer)
30
+              4.3. keepalive_processes (integer)
31
+              4.4. keepalive_interval (integer)
32
+              4.5. ping_application_data (string)
33
+              4.6. sub_protocols (integer)
34
+              4.7. cors_mode (integer)
35
+
36
+        5. Functions
37
+
38
+              5.1. ws_handle_handshake()
39
+              5.2. ws_close([status, reason[, connection_id]])
40
+
41
+        6. MI Commands
42
+
43
+              6.1. ws.dump
44
+              6.2. ws.close
45
+              6.3. ws.ping
46
+              6.4. ws.pong
47
+              6.5. ws.disable
48
+              6.6. ws.enable
49
+
50
+        7. Event routes
51
+
52
+              7.1. websocket:closed
53
+
54
+        8. Exported Pseudo Variables
55
+
56
+              8.1. $ws_conid
57
+
58
+   List of Examples
59
+
60
+   1.1. event_route[xhttp:request]
61
+   1.2. WebSocket SIP Routing
62
+   1.3. Set keepalive_mechanism parameter
63
+   1.4. Set keepalive_timeout parameter
64
+   1.5. Set keepalive_processes parameter
65
+   1.6. Set keepalive_interval parameter
66
+   1.7. Set ping_application_data parameter
67
+   1.8. Set sub_protocols parameter
68
+   1.9. Set cors_mode parameter
69
+   1.10. ws_handle_handshake usage
70
+   1.11. ws_close usage
71
+   1.12. event_route[websocket:closed] usage
72
+   1.13. $ws_conid usage
73
+
74
+Chapter 1. Admin Guide
75
+
76
+   Table of Contents
77
+
78
+   1. Overview
79
+   2. How it works
80
+
81
+        2.1. Initiating a connection
82
+        2.2. SIP message routing
83
+        2.3. MSRP message routing
84
+
85
+   3. Dependencies
86
+
87
+        3.1. Kamailio Modules
88
+        3.2. External Libraries or Applications
89
+
90
+   4. Parameters
91
+
92
+        4.1. keepalive_mechanism (integer)
93
+        4.2. keepalive_timeout (integer)
94
+        4.3. keepalive_processes (integer)
95
+        4.4. keepalive_interval (integer)
96
+        4.5. ping_application_data (string)
97
+        4.6. sub_protocols (integer)
98
+        4.7. cors_mode (integer)
99
+
100
+   5. Functions
101
+
102
+        5.1. ws_handle_handshake()
103
+        5.2. ws_close([status, reason[, connection_id]])
104
+
105
+   6. MI Commands
106
+
107
+        6.1. ws.dump
108
+        6.2. ws.close
109
+        6.3. ws.ping
110
+        6.4. ws.pong
111
+        6.5. ws.disable
112
+        6.6. ws.enable
113
+
114
+   7. Event routes
115
+
116
+        7.1. websocket:closed
117
+
118
+   8. Exported Pseudo Variables
119
+
120
+        8.1. $ws_conid
121
+
122
+1. Overview
123
+
124
+   This module implements a WebSocket (RFC 6455) server and provides
125
+   connection establishment (handshaking), management (including
126
+   connection keep-alive), and framing for the SIP and MSRP WebSocket
127
+   sub-protocols (draft-ietf-sipcore-sip-websocket and
128
+   draft-pd-msrp-websocket).
129
+
130
+   The module supports WebSockets (ws) and secure WebSockets (wss)
131
+
132
+2. How it works
133
+
134
+   2.1. Initiating a connection
135
+   2.2. SIP message routing
136
+   2.3. MSRP message routing
137
+
138
+2.1. Initiating a connection
139
+
140
+   A WebSocket connection is initiated with an HTTP GET. The xhttp module
141
+   is used to handle this GET and call the Section 5.1, “
142
+   ws_handle_handshake() ” exported function.
143
+
144
+   event_route[xhttp:request] should perform some validation of the HTTP
145
+   headers before calling Section 5.1, “ ws_handle_handshake() ”. The
146
+   event_route can also be used to make sure the HTTP GET has the correct
147
+   URI, perform HTTP authentication on the WebSocket connection, and check
148
+   the Origin header (RFC 6454) to ensure a browser-based SIP UA or MSRP
149
+   client has been downloaded from the correct location.
150
+
151
+   Example 1.1. event_route[xhttp:request]
152
+...
153
+loadmodule "sl.so"
154
+loadmodule "xhttp.so"
155
+loadmodule "msrp.so"  # Only required if using MSRP over WebSockets
156
+loadmodule "websocket.so"
157
+...
158
+event_route[xhttp:request] {
159
+        set_reply_close();
160
+        set_reply_no_connect();
161
+
162
+        if ($Rp != 80
163
+#!ifdef WITH_TLS
164
+            && $Rp != 443
165
+#!endif
166
+        ) {
167
+
168
+                xlog("L_WARN", "HTTP request received on $Rp\n");
169
+                xhttp_reply("403", "Forbidden", "", "");
170
+                exit;
171
+        }
172
+
173
+        xlog("L_DBG", "HTTP Request Received\n");
174
+
175
+        if ($hdr(Upgrade)=~"websocket"
176
+                        && $hdr(Connection)=~"Upgrade"
177
+                        && $rm=~"GET") {
178
+
179
+                # Validate Host - make sure the client is using the correct
180
+                # alias for WebSockets
181
+                if ($hdr(Host) == $null || !is_myself("sip:" + $hdr(Host))) {
182
+                        xlog("L_WARN", "Bad host $hdr(Host)\n");
183
+                        xhttp_reply("403", "Forbidden", "", "");
184
+                        exit;
185
+                }
186
+
187
+                # Optional... validate Origin - make sure the client is from an
188
+                # authorised website.  For example,
189
+                #
190
+                # if ($hdr(Origin) != "http://communicator.MY_DOMAIN"
191
+                #     && $hdr(Origin) != "https://communicator.MY_DOMAIN") {
192
+                #       xlog("L_WARN", "Unauthorised client $hdr(Origin)\n");
193
+                #       xhttp_reply("403", "Forbidden", "", "");
194
+                #       exit;
195
+                # }
196
+
197
+                # Optional... perform HTTP authentication
198
+
199
+                # ws_handle_handshake() exits (no further configuration file
200
+                # processing of the request) when complete.
201
+                if (ws_handle_handshake())
202
+                {
203
+                        # Optional... cache some information about the
204
+                        # successful connection
205
+                        exit;
206
+                }
207
+        }
208
+
209
+        xhttp_reply("404", "Not found", "", "");
210
+}
211
+...
212
+
213
+2.2. SIP message routing
214
+
215
+   SIP over WebSockets uses invalid URIs in routing headers (Contact:,
216
+   Record-Route:, and Via:) because a JavaScript stack running in a
217
+   browser has no way to determine the local address from which the
218
+   WebSocket connection is made. This means that the routing headers
219
+   cannot be used for request or response routing in the normal manner.
220
+
221
+   draft-ietf-sipcore-sip-websocket states that SIP WebSocket Clients and
222
+   the SIP registrar should implement Outbound (RFC 5626) and Path (RFC
223
+   3327) to enable requests and responses to be correctly routed. However,
224
+   Kamailio does not currently support Outbound and it may not be possible
225
+   to guarantee all SIP WebSocket clients will support Outbound and Path.
226
+
227
+   The nathelper module functions (nat_uac_test(), fix_nated_register(),
228
+   add_contact_alias(), and handle_ruri_alias()) and the Kamailio core
229
+   force_rport() can be used to ensure correct routing of SIP WebSocket
230
+   requests without using Outbound and Path.
231
+
232
+   Example 1.2. WebSocket SIP Routing
233
+...
234
+loadmodule "sl.so"
235
+loadmodule "tm.so"
236
+...
237
+loadmodule "websocket.so"
238
+...
239
+request_route {
240
+
241
+        # per request initial checks
242
+        route(REQINIT);
243
+
244
+        if (nat_uac_test(64)) {
245
+                # Do NAT traversal stuff for requests from a WebSocket
246
+                # connection - even if it is not behind a NAT!
247
+                # This won't be needed in the future if Kamailio and the
248
+                # WebSocket client support Outbound and Path.
249
+                force_rport();
250
+                if (is_method("REGISTER"))
251
+                        fix_nated_register();
252
+                else {
253
+                        if (!add_contact_alias()) {
254
+                                xlog("L_ERR", "Error aliasing contact <$ct>\n");
255
+                                sl_send_reply("400", "Bad Request");
256
+                                exit;
257
+                        }
258
+                }
259
+        }
260
+
261
+        if (!is_method("REGISTER"))
262
+                t_on_reply("WS_REPLY");
263
+...
264
+# Handle requests within SIP dialogs
265
+route[WITHINDLG] {
266
+        if (has_totag()) {
267
+                # sequential request withing a dialog should
268
+                # take the path determined by record-routing
269
+                if (loose_route()) {
270
+                        if ($du == "") {
271
+                                if (!handle_ruri_alias()) {
272
+                                        xlog("L_ERR", "Bad alias <$ru>\n");
273
+                                        sl_send_reply("400", "Bad Request");
274
+                                        exit;
275
+                                }
276
+                        }
277
+                        route(RELAY);
278
+                } else {
279
+                        if ( is_method("ACK") ) {
280
+...
281
+onreply_route[WS_REPLY] {
282
+        if (nat_uac_test(64)) {
283
+                # Do NAT traversal stuff for replies to a WebSocket connection
284
+                # - even if it is not behind a NAT!
285
+                # This won't be needed in the future if Kamailio and the
286
+                # WebSocket client support Outbound and Path.
287
+                add_contact_alias();
288
+        }
289
+}
290
+...
291
+
292
+2.3. MSRP message routing
293
+
294
+   MSRP over WebSocket clients create invalid local URIs for use in Path
295
+   headers (From-Path: and To-Path:) because a JavaScript stack running in
296
+   a browser has no way to determine the local address from which the
297
+   WebSocket connection is made. This is OK because MSRP over WebSocket
298
+   clients MUST use an MSRP relay and it is the MSRP relay's
299
+   responsibility to select the correct connection to the client based on
300
+   the MSRP URIs that it has created (and maintains a mapping for).
301
+
302
+3. Dependencies
303
+
304
+   3.1. Kamailio Modules
305
+   3.2. External Libraries or Applications
306
+
307
+3.1. Kamailio Modules
308
+
309
+   The following module must be loaded before this module:
310
+     * sl.
311
+     * tm.
312
+
313
+   The following modules are required to make proper use of this module:
314
+     * nathelper or outbound.
315
+     * xhttp.
316
+
317
+   The following module is required to use the secure WebSocket (wss)
318
+   scheme:
319
+     * tls.
320
+
321
+   The following module is required to support MSRP over WebSockets:
322
+     * msrp.
323
+
324
+3.2. External Libraries or Applications
325
+
326
+   The following libraries must be installed before running Kamailio with
327
+   this module loaded:
328
+     * OpenSSL.
329
+     * GNU libunistring.
330
+
331
+4. Parameters
332
+
333
+   4.1. keepalive_mechanism (integer)
334
+   4.2. keepalive_timeout (integer)
335
+   4.3. keepalive_processes (integer)
336
+   4.4. keepalive_interval (integer)
337
+   4.5. ping_application_data (string)
338
+   4.6. sub_protocols (integer)
339
+   4.7. cors_mode (integer)
340
+
341
+4.1. keepalive_mechanism (integer)
342
+
343
+   The keep-alive mechanism to use for WebSocket connections.
344
+
345
+Note
346
+
347
+   If nathelper is only being used for WebSocket connections then
348
+   nathelper NAT pinging is not required. If nathelper is used for
349
+   WebSocket connections and TCP/TLS aliasing/NAT-traversal then WebSocket
350
+   keep-alives are not required.
351
+
352
+     * 0 - no WebSocket keep-alives
353
+     * 1 - Ping WebSocket keep-alives
354
+     * 2 - Pong WebSocket keep-alives
355
+
356
+   Default value is 1.
357
+
358
+   Example 1.3. Set keepalive_mechanism parameter
359
+...
360
+modparam("websocket", "keepalive_mechanism", 0)