{"id":16483000,"url":"https://github.com/ilyamatsuev/apex-websocket-client","last_synced_at":"2026-02-07T01:03:29.565Z","repository":{"id":133552010,"uuid":"450537515","full_name":"IlyaMatsuev/Apex-WebSocket-Client","owner":"IlyaMatsuev","description":"The library for handling sending and receiving updates by WebSocket protocol in Apex.","archived":false,"fork":false,"pushed_at":"2023-02-05T18:54:58.000Z","size":107,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-14T05:28:57.082Z","etag":null,"topics":["apex","library","salesforce","salesforce-apex","websocket","websocket-client","websockets","ws","wss"],"latest_commit_sha":null,"homepage":"","language":"Apex","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IlyaMatsuev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-21T15:12:26.000Z","updated_at":"2024-10-31T14:33:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"f378260d-6cd7-47c8-9ddf-07c5a3f7ad6a","html_url":"https://github.com/IlyaMatsuev/Apex-WebSocket-Client","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/IlyaMatsuev/Apex-WebSocket-Client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlyaMatsuev%2FApex-WebSocket-Client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlyaMatsuev%2FApex-WebSocket-Client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlyaMatsuev%2FApex-WebSocket-Client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlyaMatsuev%2FApex-WebSocket-Client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IlyaMatsuev","download_url":"https://codeload.github.com/IlyaMatsuev/Apex-WebSocket-Client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IlyaMatsuev%2FApex-WebSocket-Client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29183299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T00:44:15.062Z","status":"ssl_error","status_checked_at":"2026-02-07T00:35:01.758Z","response_time":59,"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":["apex","library","salesforce","salesforce-apex","websocket","websocket-client","websockets","ws","wss"],"created_at":"2024-10-11T13:12:43.213Z","updated_at":"2026-02-07T01:03:29.546Z","avatar_url":"https://github.com/IlyaMatsuev.png","language":"Apex","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apex WebSocket Client\n\n[![Scratch Org CI](https://github.com/IlyaMatsuev/Apex-WebSocket-Client/actions/workflows/scratch-org-ci.yml/badge.svg?branch=main)](https://github.com/IlyaMatsuev/Apex-WebSocket-Client/actions/workflows/scratch-org-ci.yml)\n[![Test Coverage](https://codecov.io/gh/IlyaMatsuev/Apex-WebSocket-Client/branch/main/graph/badge.svg?token=PSRCUDWM3P)](https://codecov.io/gh/IlyaMatsuev/Apex-WebSocket-Client)\n\nSalesforce Apex library that is aimed to provide support for the WebSocket protocol. Which can be used directly from Apex runtime (not only via LWC JS).\n\nOf course, there is no native support for WebSocket in Apex yet. This project uses an external server that redirects HTTP requests as WebSocket messages.\n\n## Overview\n\nTo handle WebSocket events you need to create a handler class that is going to handle incoming messages, errors, or connection closing:\n\n```java\npublic class WebSocketMessageHandler implements IWSMessageHandler {\n    public void handle(WSConnection connection, Map\u003cString, Object\u003e args) {\n        // Get the new incoming messages (if there are any)\n        List\u003cString\u003e newMessages = connection.getUpdates();\n\n        // Send a message back to the WebSocket server\n        connection.send('Message back!');\n\n        // We can also request closing connection if we need to\n        //connection.close();\n    }\n}\n```\n\nThis is how you connect to the WebSocket server:\n\n```java\nWSClient client = new WSClient();\n// Register onMessage event handler\nclient.onMessage(WebSocketMessageHandler.class);\n// Connect to the WebSocket server and receive the connection object\nWSConnection connection = client.connect('wss://some-ws-endpoint.com');\n// With the connection object we can send a new message or close the connection\nconnection.send('Hello World!');\n```\n\nFor more examples, please refer to [here](docs/examples).\n\n**Be aware, that this package uses a lot of Platform Events and Queueable Apex jobs to make things work. It can affect your organization's [governor limits](https://developer.salesforce.com/docs/atlas.en-us.234.0.platform_events.meta/platform_events/platform_event_limits.htm).**  \n_Let's say we receive a new message every 10 seconds. For a minute of an established connection, it submits approximately 2-4 Queueable Apex jobs and fires 6-18 Platform Events (depending on the amount of registered handlers)._\n\n## Installation\n\n### From Unmanaged Package\n\nYou can just install the package by the link on a [sandbox](https://test.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001zNZfQAM) or [dev org](https://login.salesforce.com/packaging/installPackage.apexp?p0=04t5Y000001zNZfQAM).\n\nIf you prefer using salesforce CLI you can run:\n\n```\nsfdx force:package:install -p 04t5Y000001zNZfQAM -w 10 -b 10 -u \u003cusername\u003e\n```\n\n### From Source\n\nYou can also install the package with the automated scripts: [`pkg-deploy.sh`](scripts/pkg-deploy.sh) and [`pkg-from-scratch.sh`](scripts/pkg-from-scratch.sh).  \nFirst is for deploying changes to the existing org.\n\n```\n./scripts/pkg-deploy.sh \u003cusername_or_alias\u003e\n```\n\nSecond is for creating a new configured scratch org.\n\n```\n./scripts/pkg-from-scratch.sh \u003cdevhub_username_or_alias\u003e \u003cnew_scratch_org_alias\u003e\n```\n\n## Configuration\n\nThe library can be used as it is without any additional configuration, or it can be used with your own server running (which is recommended). For more details about how to run your server instance visit [this page](src/ws-dispatcher).\n\nAlso, don't forget to assign the `ApexWSClientUser` permission set to the necessary users and update the [`WSDispatcherSetting__c`](docs/README.md#wsdispatchersettingc) custom settings.\n\n## Documentation\n\nFor more detailed information about the content of the repository and sfdx package, please visit [docs folder](docs).\n\n## Questions\n\nIf you have any questions you can start a discussion.  \nIf you think something works not as expected or you want to request a new feature, you can create an issue with the appropriate template selected.\n\n## Contributing\n\nPull requests are welcome.  \nFor major changes, please open an issue first to discuss what you would like to change.  \nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filyamatsuev%2Fapex-websocket-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filyamatsuev%2Fapex-websocket-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filyamatsuev%2Fapex-websocket-client/lists"}