{"id":15667735,"url":"https://github.com/holsee/wizz","last_synced_at":"2025-05-06T19:47:49.001Z","repository":{"id":68409020,"uuid":"127309228","full_name":"holsee/wizz","owner":"holsee","description":"Demo application showing  cowboy WebSockets in elixir with Plug","archived":false,"fork":false,"pushed_at":"2018-04-03T15:38:20.000Z","size":18,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T17:44:09.802Z","etag":null,"topics":["cowboy","elixir","plug","websockets"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/holsee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-29T15:14:00.000Z","updated_at":"2023-12-07T01:45:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"624dd1e5-29fa-45b3-9ff5-c8c64ee179c9","html_url":"https://github.com/holsee/wizz","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holsee%2Fwizz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holsee%2Fwizz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holsee%2Fwizz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/holsee%2Fwizz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/holsee","download_url":"https://codeload.github.com/holsee/wizz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242811746,"owners_count":20189127,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cowboy","elixir","plug","websockets"],"created_at":"2024-10-03T14:05:07.839Z","updated_at":"2025-03-10T07:32:45.560Z","avatar_url":"https://github.com/holsee.png","language":"Elixir","readme":"# Wizz\n\nDemo App to showcase using Cowboy HTTP(S) and WebSockets in Elixir \u0026 Plug.\n\n## Change Log\n\n* Refer to tag 1.1.x / branch cowboy-1.1.x for Cowboy 1 version.\n* Updated to include configuring cowboy to use secure transport.\n* Implemented secure transport for WebSockets and HTTP handler.\n* Swapped `WebSockex` for `Socket` in order to ensure secure transport.\n* Added Generic Server wrapper `WebSocketClient` around `Socket`.\n\n## Configuration\n\n### Set Transport Scheme\n\nEdit `config/config.exs` and set scheme to `:http` or `:https`\n``` elixir\nconfig :wizz,\n  scheme: :http | :https\n```\n\n## Run Server\n\n```\n$ iex -S mix\n```\n\n## Examples\n\n### HTTPS Endpoint\n\nEnsure `scheme` is set to `:https`.\n\nI followed http://ezgr.net/increasing-security-erlang-ssl-cowboy/ when selecting\nthe secure transport options for cowboy.\n\nRequest `/ping` endpoint over `https://`:\n```\n$ curl https://localhost:1447/ping --cacert \"./priv/ssl/cacert.crt\"\npong\n```\n\n### Secure WebSocket\n\nSame as `HTTP` examples below, except with `https://` in protocol in URI.\n\nNote that it is also, it is possible it use `Wizz.Client.start_link/0` which\nwill automatically compute the websocket URI endpoint / port / scheme based\non the server configuration.\n\n### HTTP Endpoint\n\n```\n$ curl http://localhost:1447/ping\npong\n```\n\n```\n$ curl http://localhost:1447/other\n¯\\_(ツ)_/¯ 404\n```\n\n### WebSocket\n\nI have included a websocket client module to demonstrating connecting to the\nwebsocket endpoint: `Wizz.Client`.\n\nStart Server with Console:\n```\n$ iex -S mix\n```\n\nCreate a WebSocket connection (spawn a client process):\n``` elixir\n# Establish WebSocket Connection\n{:ok, client} = Wizz.Client.start_link(\"http://localhost:1447/ws\")\n```\n\nDebug Log showing `SocketHandler` process spawned:\n```\n00:00:00.000 pid=\u003c0.324.0\u003e module=Wizz.SocketHandler [debug] websocket_init :tcp, []\n```\n\nIf we establish another connection:\n```\n{:ok, c} = Wizz.Client.start_link(\"http://localhost:1447/ws\")\n```\n\nAnother process is spawned to handle this connection:\n```\n00:00:00.157 pid=\u003c0.289.0\u003e module=Wizz.SocketHandler [debug] init []\n```\n\nSend `ping`:\n``` elixir\nWizz.Client.send(c, {:text, \"ping\"})\n```\n\n_Client Log_: send `ping` message (expect `pong`):\n```\n00:00:00.624 pid=\u003c0.295.0\u003e module=WebSocketClient [debug] Sending text frame with payload: ping\n```\n\n_Server Log_: `ping` received, sending `pong`:\n```\n00:00:00.624 pid=\u003c0.300.0\u003e module=Wizz.SocketHandler [debug] received: ping; sending: pong\n```\n\n_Client Log_: received `pong`\n```\n00:00:00.626 pid=\u003c0.295.0\u003e module=Wizz.Client [debug] Received Message - Type: :text -- Message: \"pong\"\n```\n\nSend arbitrary message:\n\n``` elixir\nWizz.Client.send(c, {:text, \"wow!\"})\n```\n\n_Client Log_: Sending `\"wow!\"`\n```\n00:00:00.547 pid=\u003c0.295.0\u003e module=Wizz.Client [debug] Sending text frame with payload: wow!\n```\n\n_Server Log_: received `\"wow!\"`, no reply\n```\n00:00:00.548 pid=\u003c0.300.0\u003e module=Wizz.SocketHandler [debug] received: wow!\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholsee%2Fwizz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fholsee%2Fwizz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fholsee%2Fwizz/lists"}