Merge branch '2.x' of github.com:beyondcode/laravel-websockets into fix/app-connections-count

This commit is contained in:
Alex Renoki 2020-09-05 10:29:08 +03:00
commit b45d786bfd
4 changed files with 20 additions and 28 deletions

View File

@ -270,28 +270,20 @@ You know you've reached this limit of your Nginx error logs contain similar mess
Remember to restart your Nginx after you've modified the `worker_connections`. Remember to restart your Nginx after you've modified the `worker_connections`.
### Example using Caddy ### Example using Caddy v2
[Caddy](https://caddyserver.com) can also be used to automatically obtain a TLS certificate from Let's Encrypt and terminate TLS before proxying to your echo server. [Caddy](https://caddyserver.com) can also be used to automatically obtain a TLS certificate from Let's Encrypt and terminate TLS before proxying to your websocket server.
An example configuration would look like this: An example configuration would look like this:
``` ```
socket.yourapp.tld { socket.yourapp.tld {
rewrite / { @ws {
if {>Connection} has Upgrade header Connection *Upgrade*
if {>Upgrade} is websocket header Upgrade websocket
to /websocket-proxy/{path}?{query}
} }
reverse_proxy @ws 127.0.0.1:6001
proxy /websocket-proxy 127.0.0.1:6001 {
without /special-websocket-url
transparent
websocket
}
tls youremail.com
} }
``` ```
Note the `to /websocket-proxy`, this is a dummy path to allow the `proxy` directive to only proxy on websocket connections. This should be a path that will never be used by your application's routing. Also, note that you should change `127.0.0.1` to the hostname of your websocket server. For example, if you're running in a Docker environment, this might be the container name of your websocket server. Note that you should change `127.0.0.1` to the hostname of your websocket server. For example, if you're running in a Docker environment, this might be the container name of your websocket server.

View File

@ -6,7 +6,7 @@ use BeyondCode\LaravelWebSockets\Exceptions\InvalidApp;
class App class App
{ {
/** @var int */ /** @var string|int */
public $id; public $id;
/** @var string */ /** @var string */
@ -39,7 +39,7 @@ class App
/** /**
* Find the app by id. * Find the app by id.
* *
* @param mixed $appId * @param string|int $appId
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public static function findById($appId) public static function findById($appId)
@ -50,7 +50,7 @@ class App
/** /**
* Find the app by app key. * Find the app by app key.
* *
* @param mixed $appId * @param string $appKey
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public static function findByKey($appKey): ?self public static function findByKey($appKey): ?self
@ -61,7 +61,7 @@ class App
/** /**
* Find the app by app secret. * Find the app by app secret.
* *
* @param mixed $appId * @param string $appSecret
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public static function findBySecret($appSecret): ?self public static function findBySecret($appSecret): ?self
@ -72,9 +72,9 @@ class App
/** /**
* Initialize the Web Socket app instance. * Initialize the Web Socket app instance.
* *
* @param mixed $appId * @param string|int $appId
* @param mixed $key * @param string $key
* @param mixed $secret * @param string $secret
* @return void * @return void
* @throws \BeyondCode\LaravelWebSockets\Exceptions\InvalidApp * @throws \BeyondCode\LaravelWebSockets\Exceptions\InvalidApp
*/ */

View File

@ -14,7 +14,7 @@ interface AppManager
/** /**
* Get app by id. * Get app by id.
* *
* @param mixed $appId * @param string|int $appId
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public function findById($appId): ?App; public function findById($appId): ?App;
@ -22,7 +22,7 @@ interface AppManager
/** /**
* Get app by app key. * Get app by app key.
* *
* @param mixed $appKey * @param string $appKey
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public function findByKey($appKey): ?App; public function findByKey($appKey): ?App;
@ -30,7 +30,7 @@ interface AppManager
/** /**
* Get app by secret. * Get app by secret.
* *
* @param mixed $appSecret * @param string $appSecret
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public function findBySecret($appSecret): ?App; public function findBySecret($appSecret): ?App;

View File

@ -38,7 +38,7 @@ class ConfigAppManager implements AppManager
/** /**
* Get app by id. * Get app by id.
* *
* @param mixed $appId * @param string|int $appId
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public function findById($appId): ?App public function findById($appId): ?App
@ -53,7 +53,7 @@ class ConfigAppManager implements AppManager
/** /**
* Get app by app key. * Get app by app key.
* *
* @param mixed $appKey * @param string $appKey
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public function findByKey($appKey): ?App public function findByKey($appKey): ?App
@ -68,7 +68,7 @@ class ConfigAppManager implements AppManager
/** /**
* Get app by secret. * Get app by secret.
* *
* @param mixed $appSecret * @param string $appSecret
* @return \BeyondCode\LaravelWebSockets\Apps\App|null * @return \BeyondCode\LaravelWebSockets\Apps\App|null
*/ */
public function findBySecret($appSecret): ?App public function findBySecret($appSecret): ?App