{"id":37710445,"url":"https://github.com/wwww-wwww/phxsocket","last_synced_at":"2026-01-16T13:18:22.894Z","repository":{"id":53052601,"uuid":"262643827","full_name":"wwww-wwww/phxsocket","owner":"wwww-wwww","description":"Phoenix websocket client for Python","archived":false,"fork":false,"pushed_at":"2024-08-16T06:22:03.000Z","size":48,"stargazers_count":19,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-29T01:09:37.154Z","etag":null,"topics":["phoenix-channels","phoenix-elixir","phoenix-framework","python","python3","websocket","websocket-client","websockets"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/phxsocket","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wwww-wwww.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-09T19:27:40.000Z","updated_at":"2025-04-14T14:46:19.000Z","dependencies_parsed_at":"2022-09-04T09:51:57.055Z","dependency_job_id":null,"html_url":"https://github.com/wwww-wwww/phxsocket","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/wwww-wwww/phxsocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwww-wwww%2Fphxsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwww-wwww%2Fphxsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwww-wwww%2Fphxsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwww-wwww%2Fphxsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wwww-wwww","download_url":"https://codeload.github.com/wwww-wwww/phxsocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwww-wwww%2Fphxsocket/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479007,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["phoenix-channels","phoenix-elixir","phoenix-framework","python","python3","websocket","websocket-client","websockets"],"created_at":"2026-01-16T13:18:22.809Z","updated_at":"2026-01-16T13:18:22.881Z","avatar_url":"https://github.com/wwww-wwww.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phxsocket\n\n### Synchronous phoenix websocket client using callbacks\n\n[Phoenix channels](https://hexdocs.pm/phoenix/channels.html)\n\n## Requirements\n\n`websockets`\n\n## Usage\n\n### Import the package\n\n```python\nimport phxsocket\n```\n\n### Create socket client\n\n```elixir\n# endpoint.ex\nsocket \"/socket\", MyAppWeb.Socket, websocket: true, longpoll: false\n```\n\n```python\nsocket = phxsocket.Client(\"wss://target.url/socket/websocket\", {\"name\": \"my name\"})\n```\n\nSocket params go to Phoenix.Socket connect/3\n\n### Connect and join a channel\n\n```elixir\n# mysocket.ex\ndefmodule MyAppWeb.Socket do\n  use Phoenix.Socket\n\n  channel(\"channel:*\", MyAppWeb.Channel)\n\n  def connect(%{\"name\" =\u003e name} = params, socket, _connect_info) do\n    {:ok, socket |\u003e assign(name: name)}\n  end\n\n  def id(socket), do: nil\nend\n\ndefmodule MyAppWeb.Channel do\n  use Phoenix.Channel\n\n  def join(\"channel:\" \u003c\u003e room_name, %{\"password\" =\u003e password}, socket) do\n    if password == \"1234\" do\n      {:ok, socket}\n    else\n      {:error, %{reason: \"unauthorized\"}}\n    end\n  end\nend\n```\n\n```python\nif socket.connect(): # blocking, raises exception on failure\n  channel = socket.channel(\"channel:my room\", {\"password\": \"1234\"})\n  resp = channel.join() # also blocking, raises exception on failure\n```\n\nAlternatively\n\n```python\ndef connect_to_channel(socket):\n  channel = socket.channel(\"channel:my room\", {\"password\": \"1234\"})\n  resp = channel.join()\n\nsocket.on_open = connect_to_channel\nconnection = socket.connect(blocking=False)\n\nconnection.wait() # blocking, raises exception on failure\n```\n\n### Reconnect on disconnection\n\n```python\nsocket.on_close = lambda socket: socket.connect()\n```\n\n### Subscribe to events\n\n```python\ndef do_something(payload):\n  content = payload[\"content\"]\n\nchannel.on(\"message\", do_something)\n```\n\n```elixir\nMyAppWeb.Endpoint.broadcast(\"channel:my room\", \"message\", %{\"content\": \"hello\"})\n```\n\n### Push data to a channel\n\n```elixir\ndefmodule MyAppWeb.Channel do\n...\ndef handle_in(\"message\", %{\"content\" =\u003e content}, socket) do\n  IO.inspect(\"received from #{socket.assigns.name}: #{content}\")\n  {:reply, {:ok, \"hello\"}, socket}\nend\n```\n\n```python\nchannel.push(\"message\", {\"content\": \"hello\"})\n```\n\nThis throws away the reply if the return value of handle_in is :reply\n\n### Push data and wait for a response\n\n```python\nmessage = channel.push(\"message\", {\"content\": \"hello\"}, reply=True)\npayload = message.wait_for_response() # blocking\n```\n\n### Push data and react to the response with a callback\n\n```python\ndef response(payload):\n  print(payload[\"status\"]) # ok\n  print(payload[\"response\"]) # hello\n\nchannel.push(\"message\", {\"content\": \"hello\"}, response)\n```\n\n### Leave a channel\n\n```python\nchannel.leave()\n```\n\n### Disconnect\n\n```python\nsocket.close()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwwww-wwww%2Fphxsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwwww-wwww%2Fphxsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwwww-wwww%2Fphxsocket/lists"}