1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731
|
Name
====
lua-resty-websocket - Lua WebSocket implementation for the ngx_lua module
Table of Contents
=================
* [Name](#name)
* [Status](#status)
* [Description](#description)
* [Synopsis](#synopsis)
* [Modules](#modules)
* [resty.websocket.server](#restywebsocketserver)
* [Methods](#methods)
* [new](#new)
* [set_timeout](#set_timeout)
* [send_text](#send_text)
* [send_binary](#send_binary)
* [send_ping](#send_ping)
* [send_pong](#send_pong)
* [send_close](#send_close)
* [send_frame](#send_frame)
* [recv_frame](#recv_frame)
* [resty.websocket.client](#restywebsocketclient)
* [Methods](#methods)
* [client:new](#clientnew)
* [client:connect](#clientconnect)
* [client:close](#clientclose)
* [client:set_keepalive](#clientset_keepalive)
* [client:set_timeout](#clientset_timeout)
* [client:send_text](#clientsend_text)
* [client:send_binary](#clientsend_binary)
* [client:send_ping](#clientsend_ping)
* [client:send_pong](#clientsend_pong)
* [client:send_close](#clientsend_close)
* [client:send_frame](#clientsend_frame)
* [client:recv_frame](#clientrecv_frame)
* [resty.websocket.protocol](#restywebsocketprotocol)
* [Methods](#methods)
* [protocol.recv_frame](#protocolrecv_frame)
* [protocol.build_frame](#protocolbuild_frame)
* [protocol.send_frame](#protocolsend_frame)
* [Automatic Error Logging](#automatic-error-logging)
* [Limitations](#limitations)
* [Installation](#installation)
* [TODO](#todo)
* [Community](#community)
* [English Mailing List](#english-mailing-list)
* [Chinese Mailing List](#chinese-mailing-list)
* [Bugs and Patches](#bugs-and-patches)
* [Author](#author)
* [Copyright and License](#copyright-and-license)
* [See Also](#see-also)
Status
======
This library is considered production ready.
Description
===========
This Lua library implements a WebSocket server and client libraries based on the [ngx_lua module](http://wiki.nginx.org/HttpLuaModule).
This Lua library takes advantage of ngx_lua's cosocket API, which ensures
100% nonblocking behavior.
Note that only [RFC 6455](http://tools.ietf.org/html/rfc6455) is supported. Earlier protocol revisions like "hybi-10", "hybi-07", and "hybi-00" are not and will not be considered.
Synopsis
========
```lua
local server = require "resty.websocket.server"
local wb, err = server:new{
timeout = 5000, -- in milliseconds
max_payload_len = 65535,
}
if not wb then
ngx.log(ngx.ERR, "failed to new websocket: ", err)
return ngx.exit(444)
end
local data, typ, err = wb:recv_frame()
if not data then
if not string.find(err, "timeout", 1, true) then
ngx.log(ngx.ERR, "failed to receive a frame: ", err)
return ngx.exit(444)
end
end
if typ == "close" then
-- for typ "close", err contains the status code
local code = err
-- send a close frame back:
local bytes, err = wb:send_close(1000, "enough, enough!")
if not bytes then
ngx.log(ngx.ERR, "failed to send the close frame: ", err)
return
end
ngx.log(ngx.INFO, "closing with status code ", code, " and message ", data)
return
end
if typ == "ping" then
-- send a pong frame back:
local bytes, err = wb:send_pong(data)
if not bytes then
ngx.log(ngx.ERR, "failed to send frame: ", err)
return
end
elseif typ == "pong" then
-- just discard the incoming pong frame
else
ngx.log(ngx.INFO, "received a frame of type ", typ, " and payload ", data)
end
wb:set_timeout(1000) -- change the network timeout to 1 second
bytes, err = wb:send_text("Hello world")
if not bytes then
ngx.log(ngx.ERR, "failed to send a text frame: ", err)
return ngx.exit(444)
end
bytes, err = wb:send_binary("blah blah blah...")
if not bytes then
ngx.log(ngx.ERR, "failed to send a binary frame: ", err)
return ngx.exit(444)
end
local bytes, err = wb:send_close(1000, "enough, enough!")
if not bytes then
ngx.log(ngx.ERR, "failed to send the close frame: ", err)
return
end
```
[Back to TOC](#table-of-contents)
Modules
=======
[Back to TOC](#table-of-contents)
resty.websocket.server
----------------------
To load this module, just do this
```lua
local server = require "resty.websocket.server"
```
[Back to TOC](#table-of-contents)
### Methods
[Back to TOC](#table-of-contents)
#### new
`syntax: wb, err = server:new()`
`syntax: wb, err = server:new(opts)`
Performs the websocket handshake process on the server side and returns a WebSocket server object.
In case of error, it returns `nil` and a string describing the error.
An optional options table can be specified. The following options are as follows:
* `max_payload_len`
Specifies the maximal length of payload allowed when sending and receiving WebSocket frames. Defaults to `65535`.
* `max_recv_len`
Specifies the maximal length of payload allowed when receiving WebSocket frames. Defaults to the value of `max_payload_len`.
* `max_send_len`
Specifies the maximal length of payload allowed when sending WebSocket frames. Defaults to the value of `max_payload_len`.
* `send_masked`
Specifies whether to send out masked WebSocket frames. When it is `true`, masked frames are always sent. Default to `false`.
* `timeout`
Specifies the network timeout threshold in milliseconds. You can change this setting later via the `set_timeout` method call. Note that this timeout setting does not affect the HTTP response header sending process for the websocket handshake; you need to configure the [send_timeout](http://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout) directive at the same time.
[Back to TOC](#table-of-contents)
#### set_timeout
`syntax: wb:set_timeout(ms)`
Sets the timeout delay (in milliseconds) for the network-related operations.
[Back to TOC](#table-of-contents)
#### send_text
`syntax: bytes, err = wb:send_text(text)`
Sends the `text` argument out as an unfragmented data frame of the `text` type. Returns the number of bytes that have actually been sent on the TCP level.
In case of errors, returns `nil` and a string describing the error.
[Back to TOC](#table-of-contents)
#### send_binary
`syntax: bytes, err = wb:send_binary(data)`
Sends the `data` argument out as an unfragmented data frame of the `binary` type. Returns the number of bytes that have actually been sent on the TCP level.
In case of errors, returns `nil` and a string describing the error.
[Back to TOC](#table-of-contents)
#### send_ping
`syntax: bytes, err = wb:send_ping()`
`syntax: bytes, err = wb:send_ping(msg)`
Sends out a `ping` frame with an optional message specified by the `msg` argument. Returns the number of bytes that have actually been sent on the TCP level.
In case of errors, returns `nil` and a string describing the error.
Note that this method does not wait for a pong frame from the remote end.
[Back to TOC](#table-of-contents)
#### send_pong
`syntax: bytes, err = wb:send_pong()`
`syntax: bytes, err = wb:send_pong(msg)`
Sends out a `pong` frame with an optional message specified by the `msg` argument. Returns the number of bytes that have actually been sent on the TCP level.
In case of errors, returns `nil` and a string describing the error.
[Back to TOC](#table-of-contents)
#### send_close
`syntax: bytes, err = wb:send_close()`
`syntax: bytes, err = wb:send_close(code, msg)`
Sends out a `close` frame with an optional status code and a message.
In case of errors, returns `nil` and a string describing the error.
For a list of valid status code, see the following document:
http://tools.ietf.org/html/rfc6455#section-7.4.1
Note that this method does not wait for a `close` frame from the remote end.
[Back to TOC](#table-of-contents)
#### send_frame
`syntax: bytes, err = wb:send_frame(fin, opcode, payload)`
Sends out a raw websocket frame by specifying the `fin` field (boolean value), the opcode, and the payload.
For a list of valid opcode, see
http://tools.ietf.org/html/rfc6455#section-5.2
In case of errors, returns `nil` and a string describing the error.
To control the maximal payload length allowed, you can pass the `max_payload_len` option to the `new` constructor.
To control whether to send masked frames, you can pass `true` to the `send_masked` option in the `new` constructor method. By default, unmasked frames are sent.
[Back to TOC](#table-of-contents)
#### recv_frame
`syntax: data, typ, err = wb:recv_frame()`
Receives a WebSocket frame from the wire.
In case of an error, returns two `nil` values and a string describing the error.
The second return value is always the frame type, which could be one of `continuation`, `text`, `binary`, `close`, `ping`, `pong`, or `nil` (for unknown types).
For `close` frames, returns 3 values: the extra status message (which could be an empty string), the string "close", and a Lua number for the status code (if any). For possible closing status codes, see
http://tools.ietf.org/html/rfc6455#section-7.4.1
For other types of frames, just returns the payload and the type.
For fragmented frames, the `err` return value is the Lua string "again".
[Back to TOC](#table-of-contents)
resty.websocket.client
----------------------
To load this module, just do this
```lua
local client = require "resty.websocket.client"
```
A simple example to demonstrate the usage:
```lua
local client = require "resty.websocket.client"
local wb, err = client:new()
local uri = "ws://127.0.0.1:" .. ngx.var.server_port .. "/s"
local ok, err, res = wb:connect(uri)
if not ok then
ngx.say("failed to connect: " .. err)
return
end
local data, typ, err = wb:recv_frame()
if not data then
ngx.say("failed to receive the frame: ", err)
return
end
ngx.say("received: ", data, " (", typ, "): ", err)
local bytes, err = wb:send_text("copy: " .. data)
if not bytes then
ngx.say("failed to send frame: ", err)
return
end
local bytes, err = wb:send_close()
if not bytes then
ngx.say("failed to send frame: ", err)
return
end
```
[Back to TOC](#table-of-contents)
### Methods
[Back to TOC](#table-of-contents)
#### client:new
`syntax: wb, err = client:new()`
`syntax: wb, err = client:new(opts)`
Instantiates a WebSocket client object.
In case of error, it returns `nil` and a string describing the error.
An optional options table can be specified. The following options are as follows:
* `max_payload_len`
Specifies the maximal length of payload allowed when sending and receiving WebSocket frames. Defaults to `65536`.
* `max_recv_len`
Specifies the maximal length of payload allowed when receiving WebSocket frames. Defaults to the value of `max_payload_len`.
* `max_send_len`
Specifies the maximal length of payload allowed when sending WebSocket frames. Defaults to the value of `max_payload_len`.
* `send_unmasked`
Specifies whether to send out an unmasked WebSocket frames. When it is `true`, unmasked frames are always sent. Default to `false`. RFC 6455 requires, however, that the client MUST send masked frames to the server, so never set this option to `true` unless you know what you are doing.
* `timeout`
Specifies the default network timeout threshold in milliseconds. You can change this setting later via the `set_timeout` method call.
[Back to TOC](#table-of-contents)
#### client:connect
`syntax: ok, err, res = wb:connect("ws://<host>:<port>/<path>")`
`syntax: ok, err, res = wb:connect("wss://<host>:<port>/<path>")`
`syntax: ok, err, res = wb:connect("ws://<host>:<port>/<path>", options)`
`syntax: ok, err, res = wb:connect("wss://<host>:<port>/<path>", options)`
Connects to the remote WebSocket service port and performs the websocket handshake process on the client side.
Before actually resolving the host name and connecting to the remote backend, this method will always look up the connection pool for matched idle connections created by previous calls of this method.
The third return value of this method contains the raw, plain-text response (status line and headers) to the handshake request. This allows the caller to perform additional validation and/or extract the response headers. When the connection is reused and no handshake request is sent, the string `"connection reused"` is returned in lieu of the response.
An optional Lua table can be specified as the last argument to this method to specify various connect options:
* `protocols`
Specifies all the subprotocols used for the current WebSocket session. It could be a Lua table holding all the subprotocol names or just a single Lua string.
* `origin`
Specifies the value of the `Origin` request header.
* `pool`
Specifies a custom name for the connection pool being used. If omitted, then the connection pool name will be generated from the string template `<host>:<port>`.
* `pool_size`
specify the size of the connection pool. If omitted and no
`backlog` option was provided, no pool will be created. If omitted
but `backlog` was provided, the pool will be created with a default
size equal to the value of the [lua_socket_pool_size](https://github.com/openresty/lua-nginx-module/tree/master#lua_socket_pool_size)
directive.
The connection pool holds up to `pool_size` alive connections
ready to be reused by subsequent calls to [connect](#client:connect), but
note that there is no upper limit to the total number of opened connections
outside of the pool. If you need to restrict the total number of opened
connections, specify the `backlog` option.
When the connection pool would exceed its size limit, the least recently used
(kept-alive) connection already in the pool will be closed to make room for
the current connection.
Note that the cosocket connection pool is per Nginx worker process rather
than per Nginx server instance, so the size limit specified here also applies
to every single Nginx worker process. Also note that the size of the connection
pool cannot be changed once it has been created.
This option was first introduced in the `v0.10.14` release.
* `backlog`
if specified, this module will limit the total number of opened connections
for this pool. No more connections than `pool_size` can be opened
for this pool at any time. If the connection pool is full, subsequent
connect operations will be queued into a queue equal to this option's
value (the "backlog" queue).
If the number of queued connect operations is equal to `backlog`,
subsequent connect operations will fail and return `nil` plus the
error string `"too many waiting connect operations"`.
The queued connect operations will be resumed once the number of connections
in the pool is less than `pool_size`.
The queued connect operation will abort once they have been queued for more
than `connect_timeout`, controlled by
[settimeouts](#client:set_timeout), and will return `nil` plus
the error string `"timeout"`.
This option was first introduced in the `v0.10.14` release.
* `ssl_verify`
Specifies whether to perform SSL certificate verification during the
SSL handshake if the `wss://` scheme is used.
* `headers`
Specifies custom headers to be sent in the handshake request. The table is expected to contain strings in the format `{"a-header: a header value", "another-header: another header value"}`.
* `client_cert`
Specifies a client certificate chain cdata object that will be used while TLS handshaking with remote server.
These objects can be created using
[ngx.ssl.parse_pem_cert](https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md#parse_pem_cert)
function provided by lua-resty-core.
Note that specifying the `client_cert` option requires corresponding `client_priv_key` be provided too. See below.
* `client_priv_key`
Specifies a private key corresponds to the `client_cert` option above.
These objects can be created using
[ngx.ssl.parse_pem_priv_key](https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/ssl.md#parse_pem_priv_key)
function provided by lua-resty-core.
* `host`
Specifies the value of the `Host` header sent in the handshake request. If not provided, the `Host` header will be derived from the hostname/address and port in the connection URI.
* `server_name`
Specifies the server name (SNI) to use when performing the TLS handshake with the server. If not provided, the `host` value or the `<host/addr>:<port>` from the connection URI will be used.
* `key`
Specifies the value of the `Sec-WebSocket-Key` header in the handshake request. The value should be a base64-encoded, 16 byte string conforming to the client handshake requirements of the [WebSocket RFC](https://datatracker.ietf.org/doc/html/rfc6455#section-4.1). If not provided, a key is randomly generated.
The SSL connection mode (`wss://`) requires at least `ngx_lua` 0.9.11 or OpenResty 1.7.4.1.
[Back to TOC](#table-of-contents)
#### client:close
`syntax: ok, err = wb:close()`
Closes the current WebSocket connection. If no `close` frame is sent yet, then the `close` frame will be automatically sent.
[Back to TOC](#table-of-contents)
#### client:set_keepalive
`syntax: ok, err = wb:set_keepalive(max_idle_timeout, pool_size)`
Puts the current WebSocket connection immediately into the `ngx_lua` cosocket connection pool.
You can specify the max idle timeout (in ms) when the connection is in the pool and the maximal size of the pool every nginx worker process.
In case of success, returns `1`. In case of errors, returns `nil` with a string describing the error.
Only call this method in the place you would have called the `close` method instead. Calling this method will immediately turn the current WebSocket object into the `closed` state. Any subsequent operations other than `connect()` on the current objet will return the `closed` error.
[Back to TOC](#table-of-contents)
#### client:set_timeout
`syntax: wb:set_timeout(ms)`
Identical to the `set_timeout` method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
#### client:send_text
`syntax: bytes, err = wb:send_text(text)`
Identical to the [send_text](#send_text) method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
#### client:send_binary
`syntax: bytes, err = wb:send_binary(data)`
Identical to the [send_binary](#send_binary) method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
#### client:send_ping
`syntax: bytes, err = wb:send_ping()`
`syntax: bytes, err = wb:send_ping(msg)`
Identical to the [send_ping](#send_ping) method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
#### client:send_pong
`syntax: bytes, err = wb:send_pong()`
`syntax: bytes, err = wb:send_pong(msg)`
Identical to the [send_pong](#send_pong) method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
#### client:send_close
`syntax: bytes, err = wb:send_close()`
`syntax: bytes, err = wb:send_close(code, msg)`
Identical to the [send_close](#send_close) method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
#### client:send_frame
`syntax: bytes, err = wb:send_frame(fin, opcode, payload)`
Identical to the [send_frame](#send_frame) method of the `resty.websocket.server` objects.
To control whether to send unmasked frames, you can pass `true` to the `send_unmasked` option in the `new` constructor method. By default, masked frames are sent.
[Back to TOC](#table-of-contents)
#### client:recv_frame
`syntax: data, typ, err = wb:recv_frame()`
Identical to the [recv_frame](#recv_frame) method of the `resty.websocket.server` objects.
[Back to TOC](#table-of-contents)
resty.websocket.protocol
------------------------
To load this module, just do this
```lua
local protocol = require "resty.websocket.protocol"
```
[Back to TOC](#table-of-contents)
### Methods
[Back to TOC](#table-of-contents)
#### protocol.recv_frame
`syntax: data, typ, err = protocol.recv_frame(socket, max_payload_len, force_masking)`
Receives a WebSocket frame from the wire.
[Back to TOC](#table-of-contents)
#### protocol.build_frame
`syntax: frame = protocol.build_frame(fin, opcode, payload_len, payload, masking)`
Builds a raw WebSocket frame.
[Back to TOC](#table-of-contents)
#### protocol.send_frame
`syntax: bytes, err = protocol.send_frame(socket, fin, opcode, payload, max_payload_len, masking)`
Sends a raw WebSocket frame.
[Back to TOC](#table-of-contents)
Automatic Error Logging
=======================
By default the underlying [ngx_lua](http://wiki.nginx.org/HttpLuaModule) module
does error logging when socket errors happen. If you are already doing proper error
handling in your own Lua code, then you are recommended to disable this automatic error logging by turning off [ngx_lua](http://wiki.nginx.org/HttpLuaModule)'s [lua_socket_log_errors](http://wiki.nginx.org/HttpLuaModule#lua_socket_log_errors) directive, that is,
```nginx
lua_socket_log_errors off;
```
[Back to TOC](#table-of-contents)
Limitations
===========
* This library cannot be used in code contexts like init_by_lua*, set_by_lua*, log_by_lua*, and
header_filter_by_lua* where the ngx_lua cosocket API is not available.
* The `resty.websocket` object instance cannot be stored in a Lua variable at the Lua module level,
because it will then be shared by all the concurrent requests handled by the same nginx
worker process (see
http://wiki.nginx.org/HttpLuaModule#Data_Sharing_within_an_Nginx_Worker ) and
result in bad race conditions when concurrent requests are trying to use the same `resty.websocket` instance.
You should always initiate `resty.websocket` objects in function local
variables or in the `ngx.ctx` table. These places all have their own data copies for
each request.
[Back to TOC](#table-of-contents)
Installation
============
It is recommended to use the latest [OpenResty bundle](http://openresty.org) directly where this library
is bundled and enabled by default. At least OpenResty 1.4.2.9 is required. And you need to enable LuaJIT when building your OpenResty
bundle by passing the `--with-luajit` option to its `./configure` script. No extra Nginx configuration is required.
If you want to use this library with your own Nginx build (with ngx_lua), then
you need to ensure you are using at least ngx_lua 0.9.0
(and [lua-bitop](http://bitop.luajit.org/) library if you are not using LuaJIT).
Also, You need to configure the
[lua_package_path](https://github.com/chaoslawful/lua-nginx-module#lua_package_path)
directive to add the path of your lua-resty-websocket source tree to ngx_lua's
Lua module search path, as in
```nginx
# nginx.conf
http {
lua_package_path "/path/to/lua-resty-websocket/lib/?.lua;;";
...
}
```
and then load the library in Lua:
```lua
local server = require "resty.websocket.server"
```
[Back to TOC](#table-of-contents)
TODO
====
[Back to TOC](#table-of-contents)
Community
=========
[Back to TOC](#table-of-contents)
English Mailing List
--------------------
The [openresty-en](https://groups.google.com/group/openresty-en) mailing list is for English speakers.
[Back to TOC](#table-of-contents)
Chinese Mailing List
--------------------
The [openresty](https://groups.google.com/group/openresty) mailing list is for Chinese speakers.
[Back to TOC](#table-of-contents)
Bugs and Patches
================
Please report bugs or submit patches by
1. creating a ticket on the [GitHub Issue Tracker](http://github.com/agentzh/lua-resty-websocket/issues),
1. or posting to the [OpenResty community](http://wiki.nginx.org/HttpLuaModule#Community).
[Back to TOC](#table-of-contents)
Author
======
Yichun "agentzh" Zhang (章亦春) <agentzh@gmail.com>, OpenResty Inc.
[Back to TOC](#table-of-contents)
Copyright and License
=====================
This module is licensed under the BSD license.
Copyright (C) 2013-2017, by Yichun Zhang (agentzh) <agentzh@gmail.com>, OpenResty Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[Back to TOC](#table-of-contents)
See Also
========
* Blog post [WebSockets with OpenResty](https://medium.com/p/1778601c9e05) by Aapo Talvensaari.
* the ngx_lua module: http://wiki.nginx.org/HttpLuaModule
* the websocket protocol: http://tools.ietf.org/html/rfc6455
* the [lua-resty-upload](https://github.com/agentzh/lua-resty-upload) library
* the [lua-resty-redis](https://github.com/agentzh/lua-resty-redis) library
* the [lua-resty-memcached](https://github.com/agentzh/lua-resty-memcached) library
* the [lua-resty-mysql](https://github.com/agentzh/lua-resty-mysql) library
[Back to TOC](#table-of-contents)
|