Which websockets implementation

716 views
Skip to first unread message

Amnon

unread,
Dec 12, 2022, 1:57:19 PM12/12/22
to golang-nuts
Which websocket implementation would people recommend for a new project,
now that gorilla/websocket has been archived?

Robert Engels

unread,
Dec 12, 2022, 3:35:59 PM12/12/22
to Amnon, golang-nuts
You can use the stdlib websocket. See https://github.com/robaho/go-trader/blob/master/internal/exchange/webserver.go for an example. 

On Dec 12, 2022, at 12:57 PM, Amnon <amn...@gmail.com> wrote:

Which websocket implementation would people recommend for a new project,

now that gorilla/websocket has been archived?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/b9bacd1c-62de-4f6f-b249-44464b61cdcen%40googlegroups.com.

Amnon

unread,
Dec 12, 2022, 4:14:14 PM12/12/22
to golang-nuts
By stdlib, you presumably mean the x/net/websocket package, which is simple ad has a clean API.
But it is also frozen, and  has not been updated for 6 years.
Its docs begin with a deprecation notice:

// This package currently lacks some features found in alternative
// and more actively maintained WebSocket packages:
//
//    https://godoc.org/github.com/gorilla/websocket
//    https://godoc.org/nhooyr.io/websocket

https://github.com/golang/net/blob/master/websocket/websocket.go#L8-L12

Should I ignore this notice and go ahead and build my system ontop of x/net/websocket?

What would people recommend, if I need a implementation which is robust, secure and performant?

 

Robert Engels

unread,
Dec 12, 2022, 4:22:30 PM12/12/22
to Amnon, golang-nuts
I personally like minimal packages like this. Makes them easier to tailor/debug if something goes wrong. Also simpler to take ownership/fork if needed - than a package with a ton of code. 

On Dec 12, 2022, at 3:14 PM, Amnon <amn...@gmail.com> wrote:

By stdlib, you presumably mean the x/net/websocket package, which is simple ad has a clean API.

Christian Stewart

unread,
Dec 12, 2022, 5:52:50 PM12/12/22
to Robert Engels, Amnon, golang-nuts
I've been using this one w/o issue and at scale as well;


It also supports wasm.

Juliusz Chroboczek

unread,
Dec 19, 2022, 9:27:50 PM12/19/22
to golan...@googlegroups.com
> By stdlib, you presumably mean the x/net/websocket package,

Careful with this library, it's not quite correct. Websocket is
a frame-oriented protocol, while x/net/websocket implements a simplistic
API that does not always preserve frame boundaries.

Correct implementations include:

https://github.com/gorilla/websocket
https://github.com/nhooyr/websocket

-- Juliusz

Jason E. Aten

unread,
Dec 19, 2022, 10:38:33 PM12/19/22
to golang-nuts
gorrila/websocket is a very mature library. The current maintainer stepping down doesn't change that. 
I wouldn't avoid it. The very fact that its been so stable and successful for so long that there's
nothing left to do on it is actually a recommendation.

Nice tutorial:

https://blog.markvincze.com/programmatically-refreshing-a-browser-tab-from-a-golang-application/
Reply all
Reply to author
Forward
0 new messages