All Projects → nhooyr → Websocket

nhooyr / Websocket

Licence: mit
Minimal and idiomatic WebSocket library for Go

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Websocket

Firefly
Firefly is an asynchronous web framework for rapid development of high-performance web application.
Stars: ✭ 277 (-86.24%)
Mutual labels:  websocket, http2
Blinksocks
A framework for building composable proxy protocol stack.
Stars: ✭ 587 (-70.84%)
Mutual labels:  websocket, http2
Echo
High performance, minimalist Go web framework
Stars: ✭ 21,297 (+957.97%)
Mutual labels:  websocket, http2
Cowlib
Support library for manipulating Web protocols.
Stars: ✭ 219 (-89.12%)
Mutual labels:  websocket, http2
Akka Http
The Streaming-first HTTP server/module of Akka
Stars: ✭ 1,163 (-42.23%)
Mutual labels:  websocket, http2
Polyphony
Fine-grained concurrency for Ruby
Stars: ✭ 234 (-88.38%)
Mutual labels:  websocket, http2
Mitmproxy
An interactive TLS-capable intercepting HTTP proxy for penetration testers and software developers.
Stars: ✭ 25,495 (+1166.52%)
Mutual labels:  websocket, http2
Gsnova
Private proxy solution & network troubleshooting tool.
Stars: ✭ 509 (-74.71%)
Mutual labels:  websocket, http2
Kuma
A network library implemented in C++, supports TCP/UDP/HTTP/HTTP2/WebSocket/SSL on platform Linux/Windows/OSX/iOS/Android.
Stars: ✭ 133 (-93.39%)
Mutual labels:  websocket, http2
Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+224.54%)
Mutual labels:  websocket, http2
Grizzly
Writing scalable server applications in the Java™ programming language has always been difficult. Before the advent of the Java New I/O API (NIO), thread management issues made it impossible for a server to scale to thousands of users. The Grizzly NIO framework has been designed to help developers to take advantage of the Java™ NIO API.
Stars: ✭ 209 (-89.62%)
Mutual labels:  websocket, http2
Twig
Twig - less is more's web server for golang
Stars: ✭ 98 (-95.13%)
Mutual labels:  websocket, http2
Httpcanary
A powerful capture and injection tool for the Android platform
Stars: ✭ 2,188 (+8.69%)
Mutual labels:  websocket, http2
Hunt Framework
A Web framework for D Programming Language. Full-stack high-performance.
Stars: ✭ 256 (-87.28%)
Mutual labels:  websocket, http2
Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (-64.73%)
Mutual labels:  websocket, http2
Nodefony Starter
Nodefony Starter Node.js Framework
Stars: ✭ 95 (-95.28%)
Mutual labels:  websocket, http2
Restbed
Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.
Stars: ✭ 1,551 (-22.95%)
Mutual labels:  websocket, http2
Httpexpect
End-to-end HTTP and REST API testing for Go.
Stars: ✭ 1,821 (-9.54%)
Mutual labels:  websocket
Bolt Js
A framework to build Slack apps using JavaScript
Stars: ✭ 1,971 (-2.09%)
Mutual labels:  websocket
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (-93.44%)
Mutual labels:  websocket

websocket

godoc coverage

websocket is a minimal and idiomatic WebSocket library for Go.

Install

go get nhooyr.io/websocket

Highlights

Roadmap

  • HTTP/2 #4

Examples

For a production quality example that demonstrates the complete API, see the echo example.

For a full stack example, see the chat example.

Server

http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
	c, err := websocket.Accept(w, r, nil)
	if err != nil {
		// ...
	}
	defer c.Close(websocket.StatusInternalError, "the sky is falling")

	ctx, cancel := context.WithTimeout(r.Context(), time.Second*10)
	defer cancel()

	var v interface{}
	err = wsjson.Read(ctx, c, &v)
	if err != nil {
		// ...
	}

	log.Printf("received: %v", v)

	c.Close(websocket.StatusNormalClosure, "")
})

Client

ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

c, _, err := websocket.Dial(ctx, "ws://localhost:8080", nil)
if err != nil {
	// ...
}
defer c.Close(websocket.StatusInternalError, "the sky is falling")

err = wsjson.Write(ctx, c, "hi")
if err != nil {
	// ...
}

c.Close(websocket.StatusNormalClosure, "")

Comparison

gorilla/websocket

Advantages of gorilla/websocket:

Advantages of nhooyr.io/websocket:

golang.org/x/net/websocket

golang.org/x/net/websocket is deprecated. See golang/go/issues/18152.

The net.Conn can help in transitioning to nhooyr.io/websocket.

gobwas/ws

gobwas/ws has an extremely flexible API that allows it to be used in an event driven style for performance. See the author's blog post.

However when writing idiomatic Go, nhooyr.io/websocket will be faster and easier to use.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].