{"id":13693473,"url":"https://github.com/dgrr/fastws","last_synced_at":"2026-02-13T23:43:21.054Z","repository":{"id":41612958,"uuid":"148019222","full_name":"dgrr/fastws","owner":"dgrr","description":"A fast WebSocket implementation for fasthttp and net/http. Supporting concurrent R/W operations by default.","archived":false,"fork":false,"pushed_at":"2021-06-10T14:03:46.000Z","size":176,"stargazers_count":90,"open_issues_count":3,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-11-23T02:21:27.096Z","etag":null,"topics":["fast","fasthttp","golang","low-level","peer","websocket","websocket-connection"],"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/dgrr.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":"SECURITY.md","support":null}},"created_at":"2018-09-09T11:33:17.000Z","updated_at":"2025-11-03T08:24:19.000Z","dependencies_parsed_at":"2022-07-07T03:30:27.823Z","dependency_job_id":null,"html_url":"https://github.com/dgrr/fastws","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/dgrr/fastws","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrr%2Ffastws","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrr%2Ffastws/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrr%2Ffastws/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrr%2Ffastws/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgrr","download_url":"https://codeload.github.com/dgrr/fastws/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgrr%2Ffastws/sbom","scorecard":{"id":339716,"data":{"date":"2025-08-11","repo":{"name":"github.com/dgrr/fastws","commit":"1229a88dce153ce5dadff84e986b2d37c49d4a29"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Code-Review","score":0,"reason":"Found 2/24 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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Info: Found linked content: SECURITY.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"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":"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":"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 10 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0355 / GHSA-fx95-883v-4q4h"],"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-18T05:30:13.789Z","repository_id":41612958,"created_at":"2025-08-18T05:30:13.789Z","updated_at":"2025-08-18T05:30:13.789Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29423542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T22:20:51.549Z","status":"ssl_error","status_checked_at":"2026-02-13T22:20:49.838Z","response_time":78,"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":["fast","fasthttp","golang","low-level","peer","websocket","websocket-connection"],"created_at":"2024-08-02T17:01:10.784Z","updated_at":"2026-02-13T23:43:21.034Z","avatar_url":"https://github.com/dgrr.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library"],"sub_categories":["WebSocket"],"readme":"# fastws\n\n[![Build Status](https://travis-ci.com/dgrr/fastws.svg?branch=master)](https://travis-ci.com/dgrr/fastws)\n[![codecov](https://codecov.io/gh/dgrr/fastws/branch/master/graph/badge.svg)](https://codecov.io/gh/dgrr/fastws)\n\nWebSocket library for [fasthttp](https://github.com/valyala/fasthttp). And now for net/http too.\n\nCheckout [examples](https://github.com/dgrr/fastws/blob/master/examples) to inspire yourself.\n\n# Why another WebSocket package?\n\nOther WebSocket packages does not allow concurrent Read/Write operations\nand does not provide low level access to WebSocket packet crafting.\n\nFollowing the fasthttp philosophy this library tries to avoid extra-allocations\nwhile providing concurrent access to Read/Write operations and stable API to be used\nin production allowing low level access to the WebSocket frames.\n\nTo see an example of what this package CAN do that others DONT checkout [this](https://github.com/dgrr/fastws/blob/master/examples/concurrent_server.go)\nor [this](https://github.com/dgrr/fastws/blob/master/examples/broadcast.go) examples.\n\n# How it works? (Server)\n\nOkay. It's easy. You have an\n[Upgrader](https://godoc.org/github.com/dgrr/fastws#Upgrader)\nwhich is used to upgrade your connection.\nYou must specify the\n[Handler](https://godoc.org/github.com/dgrr/fastws#Upgrader.Handler)\nto handle the request.\n\nIf you just want a WebSocket connection and don't want to be\na WebSocket expert you can just\nuse [Upgrade](https://godoc.org/github.com/dgrr/fastws#Upgrade) function passing the\nhandler.\n\n```go\nfunc main() {\n  fasthttp.ListenAndServe(\":8080\", fastws.Upgrade(wsHandler))\n}\n\nfunc wsHandler(conn *Conn) {\n  fmt.Fprintf(conn, \"Hello world\")\n}\n```\n\nAfter this point you can handle your awesome WebSocket connection.\nThe connection is automatically\n[closed](https://github.com/dgrr/fastws/blob/master/upgrader.go#L137)\nby fastws when you exit your handler. YES! You are able to close\nyour connection if you want to send a\n[close](https://godoc.org/github.com/dgrr/fastws#Conn.Close) message to the peer.\n\nIf you are looking for a low level usage of the library you can use the\n[Frame](https://godoc.org/github.com/dgrr/fastws#Frame) structure\nto handle frame by frame in a WebSocket connection.\nAlso you can use\n[Conn.ReadFrame](https://godoc.org/github.com/dgrr/fastws#Conn.ReadFrame) or\n[Conn.NextFrame](https://godoc.org/github.com/dgrr/fastws#Conn.NextFrame) to read\nframe by frame from your peers.\n\n```go\nfunc main() {\n  fasthttp.ListenAndServe(\":8080\", fastws.Upgrade(wsHandler))\n}\n\nfunc wsHandler(conn *Conn) {\n  fmt.Fprintf(conn, \"Hello world\")\n\n  fr, err := conn.NextFrame()\n  if err != nil {\n    panic(err)\n  }\n\n  fmt.Printf(\"Received: %s\\n\", fr.Payload())\n\n  ReleaseFrame(fr)\n}\n```\n\nAll of the [Conn](https://godoc.org/github.com/dgrr/fastws#Conn)\nfunctions are safe-concurrent. Ready to be used from different goroutines.\nIf you want to deal with the frames you can either use\n[Conn](https://godoc.org/github.com/dgrr/fastws#Conn) or your own net.Conn,\nbut remember to manage concurrency when using a net.Conn\n\n# How it works? (Client)\n\nJust call [Dial](https://godoc.org/github.com/dgrr/fastws#Dial).\n\n```go\nconn, err := fastws.Dial(\"ws://localhost:8080/ws\")\nif err != nil {\n  fmt.Println(err)\n}\nconn.WriteString(\"Hello\")\n```\n\n# fastws vs gorilla vs nhooyr vs gobwas\n\n| Features | [fastws](https://github.com/dgrr/fastws) | [Gorilla](https://github.com/fasthttp/websocket)| [Nhooyr](https://github.com/nhooyr/websocket) | [gowabs](https://github.com/gobwas/ws) |\n| --- | --- | --- | --- | --- |\n| Concurrent R/W                          | Yes            | No           | No. Only writes | No           |\n| Passes Autobahn Test Suite              | Mostly         | Yes          | Yes             | Mostly       |    \n| Receive fragmented message              | Yes            | Yes          | Yes             | Yes          |\n| Send close message                      | Yes            | Yes          | Yes             | Yes          |\n| Send pings and receive pongs            | Yes            | Yes          | Yes             | Yes          |\n| Get the type of a received data message | Yes            | Yes          | Yes             | Yes          |\n| Compression Extensions                  | On development | Experimental | Yes             | No (?)       |\n| Read message using io.Reader            | Not planned    | Yes          | No              | No (?)       |\n| Write message using io.WriteCloser      | Not planned    | Yes          | No              | No (?)       |\n\n# Benchmarks: fastws vs gorilla vs nhooyr vs gobwas\n\nFastws:\n```\n$ go test -bench=Fast -benchmem -benchtime=10s\nBenchmark1000FastClientsPer10Messages-8          225367248    52.6 ns/op       0 B/op   0 allocs/op\nBenchmark1000FastClientsPer100Messages-8        1000000000     5.48 ns/op      0 B/op   0 allocs/op\nBenchmark1000FastClientsPer1000Messages-8       1000000000     0.593 ns/op     0 B/op   0 allocs/op\nBenchmark100FastMsgsPerConn-8                   1000000000     7.38 ns/op      0 B/op   0 allocs/op\nBenchmark1000FastMsgsPerConn-8                  1000000000     0.743 ns/op     0 B/op   0 allocs/op\nBenchmark10000FastMsgsPerConn-8                 1000000000     0.0895 ns/op    0 B/op   0 allocs/op\nBenchmark100000FastMsgsPerConn-8                1000000000     0.0186 ns/op    0 B/op   0 allocs/op\n```\n\nGorilla:\n```\n$ go test -bench=Gorilla -benchmem -benchtime=10s\nBenchmark1000GorillaClientsPer10Messages-8       128621386    97.5 ns/op      86 B/op   1 allocs/op\nBenchmark1000GorillaClientsPer100Messages-8     1000000000    11.0 ns/op       8 B/op   0 allocs/op\nBenchmark1000GorillaClientsPer1000Messages-8    1000000000     1.12 ns/op      0 B/op   0 allocs/op\nBenchmark100GorillaMsgsPerConn-8                 849490059    14.0 ns/op       8 B/op   0 allocs/op\nBenchmark1000GorillaMsgsPerConn-8               1000000000     1.42 ns/op      0 B/op   0 allocs/op\nBenchmark10000GorillaMsgsPerConn-8              1000000000     0.143 ns/op     0 B/op   0 allocs/op\nBenchmark100000GorillaMsgsPerConn-8             1000000000     0.0252 ns/op    0 B/op   0 allocs/op\n```\n\nNhooyr:\n```\n$ go test -bench=Nhooyr -benchmem -benchtime=10s\nBenchmark1000NhooyrClientsPer10Messages-8        121254158   114 ns/op        87 B/op   1 allocs/op\nBenchmark1000NhooyrClientsPer100Messages-8      1000000000    11.1 ns/op       8 B/op   0 allocs/op\nBenchmark1000NhooyrClientsPer1000Messages-8     1000000000     1.19 ns/op      0 B/op   0 allocs/op\nBenchmark100NhooyrMsgsPerConn-8                  845071632    15.1 ns/op       8 B/op   0 allocs/op\nBenchmark1000NhooyrMsgsPerConn-8                1000000000     1.47 ns/op      0 B/op   0 allocs/op\nBenchmark10000NhooyrMsgsPerConn-8               1000000000     0.157 ns/op     0 B/op   0 allocs/op\nBenchmark100000NhooyrMsgsPerConn-8              1000000000     0.0251 ns/op    0 B/op   0 allocs/op\n```\n\nGobwas:\n```\n$ go test -bench=Gobwas -benchmem -benchtime=10s\nBenchmark1000GobwasClientsPer10Messages-8         98497042   106 ns/op        86 B/op   1 allocs/op\nBenchmark1000GobwasClientsPer100Messages-8      1000000000    13.4 ns/op       8 B/op   0 allocs/op\nBenchmark1000GobwasClientsPer1000Messages-8     1000000000     1.19 ns/op      0 B/op   0 allocs/op\nBenchmark100GobwasMsgsPerConn-8                  833576667    14.6 ns/op       8 B/op   0 allocs/op\nBenchmark1000GobwasMsgsPerConn-8                1000000000     1.46 ns/op      0 B/op   0 allocs/op\nBenchmark10000GobwasMsgsPerConn-8               1000000000     0.156 ns/op     0 B/op   0 allocs/op\nBenchmark100000GobwasMsgsPerConn-8              1000000000     0.0262 ns/op    0 B/op   0 allocs/op\n```\n\n# Stress tests\n\nThe following stress test were performed without timeouts:\n\nExecuting `tcpkali --ws -c 100 -m 'hello world!!13212312!' -r 10k localhost:8081` the tests shows the following:\n\nFastws:\n```\nTotal data sent:     267.4 MiB (280416485 bytes)\nTotal data received: 229.2 MiB (240330760 bytes)\nBandwidth per channel: 4.164⇅ Mbps (520.5 kBps)\nAggregate bandwidth: 192.172↓, 224.225↑ Mbps\nPacket rate estimate: 153966.7↓, 47866.8↑ (1↓, 1↑ TCP MSS/op)\nTest duration: 10.0048 s.\n```\n\nGorilla:\n```\nTotal data sent:     267.6 MiB (280594916 bytes)\nTotal data received: 165.8 MiB (173883303 bytes)\nBandwidth per channel: 3.632⇅ Mbps (454.0 kBps)\nAggregate bandwidth: 138.973↓, 224.260↑ Mbps\nPacket rate estimate: 215158.9↓, 74635.5↑ (1↓, 1↑ TCP MSS/op)\nTest duration: 10.0096 s.\n```\n\nNhooyr: (Don't know why is that low)\n```\nTotal data sent:     234.3 MiB (245645988 bytes)\nTotal data received: 67.7 MiB (70944682 bytes)\nBandwidth per channel: 2.532⇅ Mbps (316.5 kBps)\nAggregate bandwidth: 56.740↓, 196.461↑ Mbps\nPacket rate estimate: 92483.9↓, 50538.6↑ (1↓, 1↑ TCP MSS/op)\nTest duration: 10.0028 s\n```\n\nGobwas:\n```\nTotal data sent:     267.6 MiB (280591457 bytes)\nTotal data received: 169.5 MiB (177693000 bytes)\nBandwidth per channel: 3.664⇅ Mbps (458.0 kBps)\nAggregate bandwidth: 142.080↓, 224.356↑ Mbps\nPacket rate estimate: 189499.0↓, 66535.5↑ (1↓, 1↑ TCP MSS/op)\nTest duration: 10.0052 s.\n```\n\nThe source files are in [this](https://github.com/dgrr/fastws/tree/master/stress-tests/) folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgrr%2Ffastws","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgrr%2Ffastws","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgrr%2Ffastws/lists"}