{"id":26826703,"url":"https://github.com/hslam/websocket","last_synced_at":"2026-03-17T09:41:42.350Z","repository":{"id":57545298,"uuid":"279211962","full_name":"hslam/websocket","owner":"hslam","description":"Package websocket implements a client and server for the WebSocket protocol as specified in RFC 6455.","archived":false,"fork":false,"pushed_at":"2023-05-17T13:58:50.000Z","size":107,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-28T16:58:51.520Z","etag":null,"topics":["epoll","fast","go","golang","kqueue","netpoll","tls","upgrade-conn","upgrade-http","websocket","ws"],"latest_commit_sha":null,"homepage":"","language":"Go","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/hslam.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":"2020-07-13T04:41:07.000Z","updated_at":"2023-03-03T15:45:09.000Z","dependencies_parsed_at":"2024-06-20T19:05:44.106Z","dependency_job_id":"c8ef7cfc-08ac-46ce-9cba-e924c4274661","html_url":"https://github.com/hslam/websocket","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hslam/websocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fwebsocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fwebsocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fwebsocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fwebsocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hslam","download_url":"https://codeload.github.com/hslam/websocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hslam%2Fwebsocket/sbom","scorecard":{"id":470891,"data":{"date":"2025-08-11","repo":{"name":"github.com/hslam/websocket","commit":"2d09ff61bbdb2fe34ef2c66c9d8a944061d87bbd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/hslam/websocket/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/hslam/websocket/go.yml/master?enable=pin","Warn: downloadThenRun not pinned by hash: .github/workflows/go.yml:24","Warn: downloadThenRun not pinned by hash: .github/workflows/go.yml:39","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 downloadThenRun dependencies pinned","Info:   1 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T13:52:16.246Z","repository_id":57545298,"created_at":"2025-08-19T13:52:16.246Z","updated_at":"2025-08-19T13:52:16.246Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30620761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T08:10:05.930Z","status":"ssl_error","status_checked_at":"2026-03-17T08:10:04.972Z","response_time":56,"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":["epoll","fast","go","golang","kqueue","netpoll","tls","upgrade-conn","upgrade-http","websocket","ws"],"created_at":"2025-03-30T11:30:36.901Z","updated_at":"2026-03-17T09:41:42.332Z","avatar_url":"https://github.com/hslam.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# websocket\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/hslam/websocket)](https://pkg.go.dev/github.com/hslam/websocket)\n[![Build Status](https://github.com/hslam/websocket/workflows/build/badge.svg)](https://github.com/hslam/websocket/actions)\n[![codecov](https://codecov.io/gh/hslam/websocket/branch/master/graph/badge.svg)](https://codecov.io/gh/hslam/websocket)\n[![Go Report Card](https://goreportcard.com/badge/github.com/hslam/websocket)](https://goreportcard.com/report/github.com/hslam/websocket)\n[![LICENSE](https://img.shields.io/github/license/hslam/websocket.svg?style=flat-square)](https://github.com/hslam/websocket/blob/master/LICENSE)\n\nPackage websocket implements a client and server for the WebSocket protocol as specified in [RFC 6455](https://tools.ietf.org/html/rfc6455 \"RFC 6455\").\n\n## Feature\n* Upgrade HTTP/Conn\n* [Epoll/Kqueue](https://github.com/hslam/netpoll \"netpoll\")\n* TLS\n\n## [Benchmark](https://github.com/hslam/websocket-benchmark \"websocket-benchmark\")\n\n\u003cimg src=\"https://raw.githubusercontent.com/hslam/websocket-benchmark/master/websocket-qps.png\" width = \"400\" height = \"300\" alt=\"websocket-qps\" align=center\u003e\u003cimg src=\"https://raw.githubusercontent.com/hslam/websocket-benchmark/master/websocket-p99.png\" width = \"400\" height = \"300\" alt=\"websocket-p99\" align=center\u003e\n\n## Get started\n\n### Install\n```\ngo get github.com/hslam/websocket\n```\n### Import\n```\nimport \"github.com/hslam/websocket\"\n```\n### Usage\n#### Example\n\nserver.go\n```go\npackage main\n\nimport (\n\t\"github.com/hslam/mux\"\n\t\"github.com/hslam/websocket\"\n\t\"log\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tm := mux.New()\n\tm.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n\t\tconn, err := websocket.UpgradeHTTP(w, r)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t\tfor {\n\t\t\tvar message string\n\t\t\terr := conn.ReceiveMessage(\u0026message)\n\t\t\tif err != nil {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tconn.SendMessage(strings.ToUpper(string(message)))\n\t\t}\n\t\tconn.Close()\n\t}).GET()\n\tlog.Fatal(http.ListenAndServe(\":8080\", m))\n}\n```\n\nserver_poll.go\n```go\npackage main\n\nimport (\n\t\"github.com/hslam/netpoll\"\n\t\"github.com/hslam/websocket\"\n\t\"net\"\n\t\"strings\"\n)\n\nfunc main() {\n\tvar handler = \u0026netpoll.ConnHandler{}\n\thandler.SetUpgrade(func(conn net.Conn) (netpoll.Context, error) {\n\t\treturn websocket.Upgrade(conn, nil)\n\t})\n\thandler.SetServe(func(context netpoll.Context) error {\n\t\tws := context.(*websocket.Conn)\n\t\tvar message string\n\t\terr := ws.ReceiveMessage(\u0026message)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn ws.SendMessage(strings.ToUpper(string(message)))\n\t})\n\tif err := netpoll.ListenAndServe(\"tcp\", \":8080\", handler); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nclient.go\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/hslam/websocket\"\n\t\"time\"\n)\n\nfunc main() {\n\tconn, err := websocket.Dial(\"tcp\", \"127.0.0.1:8080\", \"/\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer conn.Close()\n\tfor i := 0; i \u003c 1; i++ {\n\t\tconn.SendMessage(\"Hello World\")\n\t\tvar message string\n\t\terr := conn.ReceiveMessage(\u0026message)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\tfmt.Println(message)\n\t\ttime.Sleep(time.Second)\n\t}\n}\n```\n\n**Output**\n```\nHELLO WORLD\n```\n\n**client.html**\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"/\u003e\n    \u003ctitle\u003eWebsocket\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003ch1\u003eUPPER\u003c/h1\u003e\n\u003cform\u003e\u003cp\u003estring: \u003cinput id=\"content\" type=\"text\" placeholder=\"input string\"\u003e\u003c/p\u003e\u003c/form\u003e\n\u003clabel id=\"result\"\u003eresult：\u003c/label\u003e\u003cbr\u003e\u003cbr\u003e\n\u003cbutton onclick=\"send()\"\u003eupper\u003c/button\u003e\n\u003cscript type=\"text/javascript\"\u003e\n    var wsuri = \"ws://127.0.0.1:8080/\";\n    var ws = new WebSocket(wsuri);\n    ws.onmessage = function(e) {\n        var result = document.getElementById('result');\n        result.innerHTML = \"result：\" + e.data;\n    }\n    function send() {\n        var msg = document.getElementById('content').value;\n        ws.send(msg);\n    }\n\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### License\nThis package is licensed under a MIT license (Copyright (c) 2020 Meng Huang)\n\n\n### Author\nwebsocket was written by Meng Huang.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fwebsocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhslam%2Fwebsocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhslam%2Fwebsocket/lists"}