A fast, well-tested and widely used WebSocket implementation for Go.

Overview

Gorilla WebSocket

GoDoc CircleCI

Gorilla WebSocket is a Go implementation of the WebSocket protocol.

Documentation

Status

The Gorilla WebSocket package provides a complete and tested implementation of the WebSocket protocol. The package API is stable.

Installation

go get github.com/gorilla/websocket

Protocol Compliance

The Gorilla WebSocket package passes the server tests in the Autobahn Test Suite using the application in the examples/autobahn subdirectory.

Gorilla WebSocket compared with other packages

github.com/gorilla golang.org/x/net
RFC 6455 Features
Passes Autobahn Test Suite Yes No
Receive fragmented message Yes No, see note 1
Send close message Yes No
Send pings and receive pongs Yes No
Get the type of a received data message Yes Yes, see note 2
Other Features
Compression Extensions Experimental No
Read message using io.Reader Yes No, see note 3
Write message using io.WriteCloser Yes No, see note 3

Notes:

  1. Large messages are fragmented in Chrome's new WebSocket implementation.
  2. The application can get the type of a received data message by implementing a Codec marshal function.
  3. The go.net io.Reader and io.Writer operate across WebSocket frame boundaries. Read returns when the input buffer is full or a frame boundary is encountered. Each call to Write sends a single frame message. The Gorilla io.Reader and io.WriteCloser operate on a single WebSocket message.
Issues
  • Implement Compression Extensions

    Implement Compression Extensions

    Draft RFC: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-17

    Work remaining:

    • [ ] Add fields to Dialer for specifying compression options.

    • [ ] Add fields to Upgrader for specifying compression options.

    • [ ] Add compression negotiation Upgrader.

    • [ ] Add compression negotiation to Dialer.

    • [ ] Add function to enable/disable write compression:

      // EnableWriteCompression enables and disables write compression of
      // subsequent text and binary messages. This function is a noop if
      // compression was not negotiated with the peer.
      func (c *Conn) EnableWriteCompression(enable bool) {
             c.enableWriteCompression = enable
      }
      
    enhancement 
    opened by garyburd 47
  • Improve

    Improve "Origin" check logic to compare scheme & ports

    This function - "checkSameOrigin" here: https://github.com/gorilla/websocket/blob/master/server.go#L74

    compares the request Host header with the request Origin header.

    I'm using a client where the Host header contains the port (which is legit according to these docs). So it has:

    Host: example.com:443
    

    (actually the client code sets it here: https://github.com/daltoniam/Starscream/blob/master/Sources/WebSocket.swift#L590 )

    The Origin header contains scheme and might contain the port (see spec here). In my case it looks like so:

    Origin: wss://example.com
    

    Since wss://example.com is equivalent to wss://example.com:443, it should match the Host above.

    I propose to enhance checkSameOrigin to support schemes, ports and default ports.

    wontfix 
    opened by battlmonstr 22
  • dead lock in websocket.Upgrade on linux/arm (raspberry pi) with crosscompile

    dead lock in websocket.Upgrade on linux/arm (raspberry pi) with crosscompile

    Testcase: Echo example (javascript client --> golang server).

    https://gist.github.com/tmichel/7390690

    ws.go cross compiled in windows for ARM (linux/raspberry pi). go version go1.8 windows/amd64 latest gorilla/websocket version.

    Problem: call to: conn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)

    does not return?

    After one or two minutes I got an exception.

    With golang ws server on windows I have no problem.

    Here is the stack dump, profile and heap:

    goroutine 19 [running]: runtime/pprof.writeGoroutineStacks(0x4a1140, 0x108a1320, 0x0, 0x10811500) C:/Go/src/runtime/pprof/pprof.go:603 +0x58 runtime/pprof.writeGoroutine(0x4a1140, 0x108a1320, 0x2, 0x20, 0x117c0) C:/Go/src/runtime/pprof/pprof.go:592 +0x30 runtime/pprof.(*Profile).WriteTo(0x4c7b90, 0x4a1140, 0x108a1320, 0x2, 0x108a1320, 0x4cd738) C:/Go/src/runtime/pprof/pprof.go:302 +0x2b0 net/http/pprof.handler.ServeHTTP(0x10896dc1, 0x9, 0x4a3110, 0x108a1320, 0x108acf00) C:/Go/src/net/http/pprof/pprof.go:209 +0x168 net/http/pprof.Index(0x4a3110, 0x108a1320, 0x108acf00) C:/Go/src/net/http/pprof/pprof.go:221 +0x17c net/http.HandlerFunc.ServeHTTP(0x358158, 0x4a3110, 0x108a1320, 0x108acf00) C:/Go/src/net/http/server.go:1942 +0x34 net/http.(*ServeMux).ServeHTTP(0x4cd738, 0x4a3110, 0x108a1320, 0x108acf00) C:/Go/src/net/http/server.go:2238 +0x108 net/http.serverHandler.ServeHTTP(0x10874080, 0x4a3110, 0x108a1320, 0x108acf00) C:/Go/src/net/http/server.go:2568 +0x7c net/http.(*conn).serve(0x1089f4a0, 0x4a36e8, 0x10877aa0) C:/Go/src/net/http/server.go:1825 +0x528 created by net/http.(*Server).Serve C:/Go/src/net/http/server.go:2668 +0x234

    goroutine 1 [IO wait]: net.runtime_pollWait(0x76da2f78, 0x72, 0x0) C:/Go/src/runtime/netpoll.go:164 +0x44 net.(*pollDesc).wait(0x108160fc, 0x72, 0x0, 0x109051c0) C:/Go/src/net/fd_poll_runtime.go:75 +0x28 net.(*pollDesc).waitRead(0x108160fc, 0xffffffff, 0x0) C:/Go/src/net/fd_poll_runtime.go:80 +0x24 net.(*netFD).accept(0x108160c0, 0x0, 0x4a1218, 0x109051c0) C:/Go/src/net/fd_unix.go:430 +0x15c net.(*TCPListener).accept(0x1080c0e0, 0x202504, 0x1089f780, 0x2fb618) C:/Go/src/net/tcpsock_posix.go:136 +0x20 net.(*TCPListener).AcceptTCP(0x1080c0e0, 0x6983c, 0x10835f18, 0x10835f1c) C:/Go/src/net/tcpsock.go:215 +0x3c net/http.tcpKeepAliveListener.Accept(0x1080c0e0, 0x358080, 0x1089f740, 0x4a3760, 0x108103c0) C:/Go/src/net/http/server.go:3044 +0x1c net/http.(*Server).Serve(0x10874080, 0x4a31f0, 0x1080c0e0, 0x0, 0x0) C:/Go/src/net/http/server.go:2643 +0x1ac net/http.(*Server).ListenAndServe(0x10874080, 0x10874080, 0x1) C:/Go/src/net/http/server.go:2585 +0x90 net/http.ListenAndServe(0x33ed25, 0x5, 0x0, 0x0, 0x108000f0, 0x108000f0) C:/Go/src/net/http/server.go:2787 +0x70 main.main() e:/gopath/src/ttt/ws/ws.go:21 +0x68

    goroutine 4 [semacquire]: sync.runtime_notifyListWait(0x10810508, 0x0) C:/Go/src/runtime/sema.go:297 +0x138 sync.(*Cond).Wait(0x10810500) C:/Go/src/sync/cond.go:57 +0x78 net/http.(*connReader).abortPendingRead(0x1084e0f0) C:/Go/src/net/http/server.go:686 +0xbc net/http.(*conn).hijackLocked(0x1090a120, 0x3583c8, 0x1090a168, 0x10912130, 0x76da2ff0, 0x241c08) C:/Go/src/net/http/server.go:292 +0x2c net/http.(*response).Hijack(0x10814090, 0x0, 0x0, 0x0, 0x0, 0x0) C:/Go/src/net/http/server.go:1892 +0xb8 github.com/gorilla/websocket.(*Upgrader).Upgrade(0x1083ad84, 0x4a3110, 0x10814090, 0x10874100, 0x10810640, 0x15, 0x10874180, 0x0) e:/gopath/src/github.com/gorilla/websocket/server.go:164 +0x314 github.com/gorilla/websocket.Upgrade(0x4a3110, 0x10814090, 0x10874100, 0x10810640, 0x400, 0x400, 0x0, 0x0, 0x10818024) e:/gopath/src/github.com/gorilla/websocket/server.go:269 +0x68 main.wsHandler(0x4a3110, 0x10814090, 0x10874100) e:/gopath/src/ttt/ws/ws.go:38 +0xac net/http.HandlerFunc.ServeHTTP(0x357fa4, 0x4a3110, 0x10814090, 0x10874100) C:/Go/src/net/http/server.go:1942 +0x34 net/http.(*ServeMux).ServeHTTP(0x4cd738, 0x4a3110, 0x10814090, 0x10874100) C:/Go/src/net/http/server.go:2238 +0x108 net/http.serverHandler.ServeHTTP(0x10874080, 0x4a3110, 0x10814090, 0x10874100) C:/Go/src/net/http/server.go:2568 +0x7c net/http.(*conn).serve(0x1090a120, 0x4a36e8, 0x10810460) C:/Go/src/net/http/server.go:1825 +0x528 created by net/http.(*Server).Serve C:/Go/src/net/http/server.go:2668 +0x234

    goroutine 5 [IO wait]: net.runtime_pollWait(0x76da2f00, 0x72, 0x1084e0fd) C:/Go/src/runtime/netpoll.go:164 +0x44 net.(*pollDesc).wait(0x108161fc, 0x72, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_poll_runtime.go:75 +0x28 net.(*pollDesc).waitRead(0x108161fc, 0x1084e0fd, 0x1) C:/Go/src/net/fd_poll_runtime.go:80 +0x24 net.(*netFD).Read(0x108161c0, 0x1084e0fd, 0x1, 0x1, 0x0, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_unix.go:250 +0x148 net.(*conn).Read(0x1080c0f8, 0x1084e0fd, 0x1, 0x1, 0x0, 0x0, 0x0) C:/Go/src/net/net.go:181 +0x58 net/http.(*connReader).backgroundRead(0x1084e0f0) C:/Go/src/net/http/server.go:656 +0x44 created by net/http.(*connReader).startBackgroundRead C:/Go/src/net/http/server.go:652 +0xd4

    goroutine 51 [IO wait]: net.runtime_pollWait(0x76da2e10, 0x72, 0x1091a000) C:/Go/src/runtime/netpoll.go:164 +0x44 net.(*pollDesc).wait(0x108164bc, 0x72, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_poll_runtime.go:75 +0x28 net.(*pollDesc).waitRead(0x108164bc, 0x1091a000, 0x1000) C:/Go/src/net/fd_poll_runtime.go:80 +0x24 net.(*netFD).Read(0x10816480, 0x1091a000, 0x1000, 0x1000, 0x0, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_unix.go:250 +0x148 net.(*conn).Read(0x10878790, 0x1091a000, 0x1000, 0x1000, 0x0, 0x0, 0x0) C:/Go/src/net/net.go:181 +0x58 net/http.(*connReader).Read(0x10896cf0, 0x1091a000, 0x1000, 0x1000, 0x0, 0x0, 0x0) C:/Go/src/net/http/server.go:754 +0x168 bufio.(*Reader).fill(0x109000c0) C:/Go/src/bufio/bufio.go:97 +0xf4 bufio.(*Reader).ReadSlice(0x109000c0, 0xa, 0x0, 0x8d, 0x5e4dff9c, 0x0, 0x0) C:/Go/src/bufio/bufio.go:338 +0x9c bufio.(*Reader).ReadLine(0x109000c0, 0x8, 0x9, 0x0, 0x0, 0x80, 0x7d30c) C:/Go/src/bufio/bufio.go:367 +0x24 net/textproto.(*Reader).readLineSlice(0x10810ec0, 0x0, 0x1f8b40, 0x1f8b54, 0x80, 0x332160) C:/Go/src/net/textproto/reader.go:55 +0x44 net/textproto.(*Reader).ReadLine(0x10810ec0, 0x108acd80, 0x80000000, 0x0, 0x80000000) C:/Go/src/net/textproto/reader.go:36 +0x1c net/http.readRequest(0x109000c0, 0x0, 0x108acd80, 0x0, 0x0) C:/Go/src/net/http/request.go:918 +0x5c net/http.(*conn).readRequest(0x1089f6e0, 0x4a36e8, 0x10811240, 0x0, 0x0, 0x0) C:/Go/src/net/http/server.go:934 +0x214 net/http.(*conn).serve(0x1089f6e0, 0x4a36e8, 0x10811240) C:/Go/src/net/http/server.go:1763 +0x3b4 created by net/http.(*Server).Serve C:/Go/src/net/http/server.go:2668 +0x234

    goroutine 52 [IO wait]: net.runtime_pollWait(0x76da2d98, 0x72, 0x10917000) C:/Go/src/runtime/netpoll.go:164 +0x44 net.(*pollDesc).wait(0x108165bc, 0x72, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_poll_runtime.go:75 +0x28 net.(*pollDesc).waitRead(0x108165bc, 0x10917000, 0x1000) C:/Go/src/net/fd_poll_runtime.go:80 +0x24 net.(*netFD).Read(0x10816580, 0x10917000, 0x1000, 0x1000, 0x0, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_unix.go:250 +0x148 net.(*conn).Read(0x108787a0, 0x10917000, 0x1000, 0x1000, 0x0, 0x0, 0x0) C:/Go/src/net/net.go:181 +0x58 net/http.(*connReader).Read(0x10896d20, 0x10917000, 0x1000, 0x1000, 0x0, 0x0, 0x0) C:/Go/src/net/http/server.go:754 +0x168 bufio.(*Reader).fill(0x10896810) C:/Go/src/bufio/bufio.go:97 +0xf4 bufio.(*Reader).ReadSlice(0x10896810, 0xa, 0x0, 0x8d, 0x1e9f4, 0x0, 0x0) C:/Go/src/bufio/bufio.go:338 +0x9c bufio.(*Reader).ReadLine(0x10896810, 0x14, 0x9, 0x10811300, 0x0, 0x80, 0x10850000) C:/Go/src/bufio/bufio.go:367 +0x24 net/textproto.(*Reader).readLineSlice(0x10811300, 0x10811300, 0x1f8b40, 0x1f8b54, 0x80, 0x332160) C:/Go/src/net/textproto/reader.go:55 +0x44 net/textproto.(*Reader).ReadLine(0x10811300, 0x108ace00, 0x80000000, 0x0, 0x80000000) C:/Go/src/net/textproto/reader.go:36 +0x1c net/http.readRequest(0x10896810, 0x0, 0x108ace00, 0x0, 0x0) C:/Go/src/net/http/request.go:918 +0x5c net/http.(*conn).readRequest(0x1089f740, 0x4a36e8, 0x108112e0, 0x0, 0x0, 0x0) C:/Go/src/net/http/server.go:934 +0x214 net/http.(*conn).serve(0x1089f740, 0x4a36e8, 0x108112e0) C:/Go/src/net/http/server.go:1763 +0x3b4 created by net/http.(*Server).Serve C:/Go/src/net/http/server.go:2668 +0x234

    goroutine 54 [IO wait]: net.runtime_pollWait(0x76da2e88, 0x72, 0x1089678d) C:/Go/src/runtime/netpoll.go:164 +0x44 net.(*pollDesc).wait(0x108faf7c, 0x72, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_poll_runtime.go:75 +0x28 net.(*pollDesc).waitRead(0x108faf7c, 0x1089678d, 0x1) C:/Go/src/net/fd_poll_runtime.go:80 +0x24 net.(*netFD).Read(0x108faf40, 0x1089678d, 0x1, 0x1, 0x0, 0x4a1938, 0x4a00e4) C:/Go/src/net/fd_unix.go:250 +0x148 net.(*conn).Read(0x10878638, 0x1089678d, 0x1, 0x1, 0x0, 0x0, 0x0) C:/Go/src/net/net.go:181 +0x58 net/http.(*connReader).backgroundRead(0x10896780) C:/Go/src/net/http/server.go:656 +0x44 created by net/http.(*connReader).startBackgroundRead C:/Go/src/net/http/server.go:652 +0xd4

    Profile: goroutine profile: total 7 2 @ 0x3d008 0x38354 0x377d8 0x135f14 0x135f64 0x1373ec 0x146b64 0x1fd88c 0x6c15c

    0x377d7 net.runtime_pollWait+0x43 C:/Go/src/runtime/netpoll.go:164

    0x135f13 net.(*pollDesc).wait+0x27 C:/Go/src/net/fd_poll_runtime.go:75

    0x135f63 net.(*pollDesc).waitRead+0x23 C:/Go/src/net/fd_poll_runtime.go:80

    0x1373eb net.(*netFD).Read+0x147 C:/Go/src/net/fd_unix.go:250

    0x146b63 net.(*conn).Read+0x57 C:/Go/src/net/net.go:181

    0x1fd88b net/http.(*connReader).backgroundRead+0x43 C:/Go/src/net/http/server.go:656

    2 @ 0x3d008 0x38354 0x377d8 0x135f14 0x135f64 0x1373ec 0x146b64 0x1fddb4 0xfd5c4 0xfe3e8 0xfe5c0 0x1a024c 0x1a00c4 0x1f8b68 0x1fedfc 0x202b18 0x6c15c

    0x377d7 net.runtime_pollWait+0x43 C:/Go/src/runtime/netpoll.go:164

    0x135f13 net.(*pollDesc).wait+0x27 C:/Go/src/net/fd_poll_runtime.go:75

    0x135f63 net.(*pollDesc).waitRead+0x23 C:/Go/src/net/fd_poll_runtime.go:80

    0x1373eb net.(*netFD).Read+0x147 C:/Go/src/net/fd_unix.go:250

    0x146b63 net.(*conn).Read+0x57 C:/Go/src/net/net.go:181

    0x1fddb3 net/http.(*connReader).Read+0x167 C:/Go/src/net/http/server.go:754

    0xfd5c3 bufio.(*Reader).fill+0xf3 C:/Go/src/bufio/bufio.go:97

    0xfe3e7 bufio.(*Reader).ReadSlice+0x9b C:/Go/src/bufio/bufio.go:338

    0xfe5bf bufio.(*Reader).ReadLine+0x23 C:/Go/src/bufio/bufio.go:367

    0x1a024b net/textproto.(*Reader).readLineSlice+0x43 C:/Go/src/net/textproto/reader.go:55

    0x1a00c3 net/textproto.(*Reader).ReadLine+0x1b C:/Go/src/net/textproto/reader.go:36

    0x1f8b67 net/http.readRequest+0x5b C:/Go/src/net/http/request.go:918

    0x1fedfb net/http.(*conn).readRequest+0x213 C:/Go/src/net/http/server.go:934

    0x202b17 net/http.(*conn).serve+0x3b3 C:/Go/src/net/http/server.go:1763

    1 @ 0x2ade84 0x2adcdc 0x2aacb4 0x2b0cb4 0x2b0f1c 0x204094 0x20502c 0x205f84 0x202c8c 0x6c15c

    0x2ade83 runtime/pprof.writeRuntimeProfile+0x77 C:/Go/src/runtime/pprof/pprof.go:632

    0x2adcdb runtime/pprof.writeGoroutine+0x73 C:/Go/src/runtime/pprof/pprof.go:594

    0x2aacb3 runtime/pprof.(*Profile).WriteTo+0x2af C:/Go/src/runtime/pprof/pprof.go:302

    0x2b0cb3 net/http/pprof.handler.ServeHTTP+0x167 C:/Go/src/net/http/pprof/pprof.go:209

    0x2b0f1b net/http/pprof.Index+0x17b C:/Go/src/net/http/pprof/pprof.go:221

    0x204093 net/http.HandlerFunc.ServeHTTP+0x33 C:/Go/src/net/http/server.go:1942

    0x20502b net/http.(*ServeMux).ServeHTTP+0x107 C:/Go/src/net/http/server.go:2238

    0x205f83 net/http.serverHandler.ServeHTTP+0x7b C:/Go/src/net/http/server.go:2568

    0x202c8b net/http.(*conn).serve+0x527 C:/Go/src/net/http/server.go:1825

    1 @ 0x3d008 0x38354 0x377d8 0x135f14 0x135f64 0x138684 0x150238 0x14e860 0x207364 0x206324 0x2060a4 0x206ca0 0x2b11fc 0x3cbc0 0x6c15c

    0x377d7 net.runtime_pollWait+0x43 C:/Go/src/runtime/netpoll.go:164

    0x135f13 net.(*pollDesc).wait+0x27 C:/Go/src/net/fd_poll_runtime.go:75

    0x135f63 net.(*pollDesc).waitRead+0x23 C:/Go/src/net/fd_poll_runtime.go:80

    0x138683 net.(*netFD).accept+0x15b C:/Go/src/net/fd_unix.go:430

    0x150237 net.(*TCPListener).accept+0x1f C:/Go/src/net/tcpsock_posix.go:136

    0x14e85f net.(*TCPListener).AcceptTCP+0x3b C:/Go/src/net/tcpsock.go:215

    0x207363 net/http.tcpKeepAliveListener.Accept+0x1b C:/Go/src/net/http/server.go:3044

    0x206323 net/http.(*Server).Serve+0x1ab C:/Go/src/net/http/server.go:2643

    0x2060a3 net/http.(*Server).ListenAndServe+0x8f C:/Go/src/net/http/server.go:2585

    0x206c9f net/http.ListenAndServe+0x6f C:/Go/src/net/http/server.go:2787

    0x2b11fb main.main+0x67 e:/gopath/src/ttt/ws/ws.go:21

    0x3cbbf runtime.main+0x1e3 C:/Go/src/runtime/proc.go:185

    1 @ 0x3d008 0x3d0d0 0x4da58 0x7cbf8 0x1fda64 0x1fc098 0x203b14 0x241c28 0x242cbc 0x2b147c 0x204094 0x20502c 0x205f84 0x202c8c 0x6c15c

    0x4da57 sync.runtime_notifyListWait+0x137 C:/Go/src/runtime/sema.go:297

    0x7cbf7 sync.(*Cond).Wait+0x77 C:/Go/src/sync/cond.go:57

    0x1fda63 net/http.(*connReader).abortPendingRead+0xbb C:/Go/src/net/http/server.go:686

    0x1fc097 net/http.(*conn).hijackLocked+0x2b C:/Go/src/net/http/server.go:292

    0x203b13 net/http.(*response).Hijack+0xb7 C:/Go/src/net/http/server.go:1892

    0x241c27 github.com/gorilla/websocket.(*Upgrader).Upgrade+0x313 e:/gopath/src/github.com/gorilla/websocket/server.go:164

    0x242cbb github.com/gorilla/websocket.Upgrade+0x67 e:/gopath/src/github.com/gorilla/websocket/server.go:269

    0x2b147b main.wsHandler+0xab e:/gopath/src/ttt/ws/ws.go:38

    0x204093 net/http.HandlerFunc.ServeHTTP+0x33 C:/Go/src/net/http/server.go:1942

    0x20502b net/http.(*ServeMux).ServeHTTP+0x107 C:/Go/src/net/http/server.go:2238

    0x205f83 net/http.serverHandler.ServeHTTP+0x7b C:/Go/src/net/http/server.go:2568

    0x202c8b net/http.(*conn).serve+0x527 C:/Go/src/net/http/server.go:1825

    HEAP:

    heap profile: 1: 16 [1: 16] @ heap/1048576 1: 16 [1: 16] @ 0x1b8c18 0x1b89e4 0x1ba7e4 0x21a100 0x2b178c 0x3cb74 0x6c15c

    0x1b8c17 vendor/golang_org/x/net/http2/hpack.addDecoderNode+0x1f3 C:/Go/src/vendor/golang_org/x/net/http2/hpack/huffman.go:144

    0x1b89e3 vendor/golang_org/x/net/http2/hpack.init.1+0x6f C:/Go/src/vendor/golang_org/x/net/http2/hpack/huffman.go:127

    0x1ba7e3 vendor/golang_org/x/net/http2/hpack.init+0x158f C:/Go/src/vendor/golang_org/x/net/http2/hpack/tables.go:353

    0x21a0ff net/http.init+0xb3 C:/Go/src/net/http/transport.go:2184

    0x2b178b main.init+0x47 e:/gopath/src/ttt/ws/ws.go:63

    0x3cb73 runtime.main+0x197 C:/Go/src/runtime/proc.go:173

    0: 0 [0: 0] @ 0x2ac4b4 0x2aacb4 0x2b0cb4 0x2b0f1c 0x204094 0x20502c 0x205f84 0x202c8c 0x6c15c

    0x2ac4b3 runtime/pprof.writeHeap+0x63 C:/Go/src/runtime/pprof/pprof.go:489

    0x2aacb3 runtime/pprof.(*Profile).WriteTo+0x2af C:/Go/src/runtime/pprof/pprof.go:302

    0x2b0cb3 net/http/pprof.handler.ServeHTTP+0x167 C:/Go/src/net/http/pprof/pprof.go:209

    0x2b0f1b net/http/pprof.Index+0x17b C:/Go/src/net/http/pprof/pprof.go:221

    0x204093 net/http.HandlerFunc.ServeHTTP+0x33 C:/Go/src/net/http/server.go:1942

    0x20502b net/http.(*ServeMux).ServeHTTP+0x107 C:/Go/src/net/http/server.go:2238

    0x205f83 net/http.serverHandler.ServeHTTP+0x7b C:/Go/src/net/http/server.go:2568

    0x202c8b net/http.(*conn).serve+0x527 C:/Go/src/net/http/server.go:1825

    runtime.MemStats

    Alloc = 417584

    TotalAlloc = 417584

    Sys = 21568636

    Lookups = 17

    Mallocs = 6452

    Frees = 396

    HeapAlloc = 417584

    HeapSys = 1703936

    HeapIdle = 688128

    HeapInuse = 1015808

    HeapReleased = 0

    HeapObjects = 6056

    Stack = 393216 / 393216

    MSpan = 10856 / 16384

    MCache = 2400 / 16384

    BuckHashSys = 722973

    GCSys = 17501184

    OtherSys = 1214559

    NextGC = 4473924

    PauseNs = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]

    NumGC = 0

    DebugGC = false

    opened by eidmanna 22
  • Add support for fasthttp

    Add support for fasthttp

    So this is a bit of a "speculative" PR in that I don't know if you guys are open to this kind of contribution and also whether the way I have written it matches the rest of the project.

    The basic idea is I need websocket support in a project which uses the relatively new Go HTTP package fasthttp.

    Gorilla websocket seemed like the best option to add this.

    As you can see in the diff I have refactored various non-exported utility functions to make them usable from both net/http and fasthttp code, and then I added a FastHTTPUpgrader. The way fasthttp does hijacking is quite a bit different (and better IMO) than net/http, so the FastHTTPUpgrader .UpgradeHandler() is quite a bit more sane than the one for the standard Upgrader.Upgrade().

    The existing tests pass but I did not add any tests for my addition. I could do that but didn't want to spend the time if this PR would be rejected.

    opened by leavengood 20
  • wss client sample

    wss client sample

    Hi .

    We are trying to create a secure WS with self signed certificates . Taken the chat sample changed home.html to use wss and it works. BUT When a GO client (already working without tls) , and are getting various results from x509: certificate signed by unknown authority if skipverify = false to tls: oversized record received with length 20527 when its true . sample client (with commented code of some of the trial and error) , server , html and cert creator (from tls package) is attached .

    chat1.zip

    Thanks, Guy .

    opened by guybrand 19
  • It eats tremendous amout of memory on high load

    It eats tremendous amout of memory on high load

    Hello I tried to use it for real time MMO game. And got a problem with garbage collector working constantly. With 1000 clients each sending and receiving 100 messages per second library generates ~10 Gb of memory in 2 minutes. In contrast, google's x/net/websocket generates about 10 times less work for gc. Here is 2 first line from profiler gathered during 2 min of work:

    (pprof) top10 12.02GB of 12.47GB total (96.38%) Dropped 63 nodes (cum <= 0.06GB) Showing top 10 nodes out of 35 (cum >= 0.10GB) flat flat% sum% cum cum% 6.73GB 53.94% 53.94% 6.73GB 53.94% bytes.makeSlice 2.30GB 18.45% 72.38% 9.02GB 72.38% io/ioutil.readAll

    Here is a place where the memory usage get generated g1 g2

    It could be easily fixed when you would allow passing pre-allocated buffers as arguments to readMessage instead of allocating it per each frame.

    I am ready to provide any further information when you are interested.

    opened by softaria-roman 19
  • Sometimes i got

    Sometimes i got "unexpected reserved bits 0x40" with client of unity by BestHttp

    My Unity client with the lib of BestHttp. And on production env, server sometimes got err "unexpected reserved bits 0x40". I don't understand, please help me, thanks.

    opened by spiderpoison 18
  • gorilla always encouter unexpected EOF, but google's version works well

    gorilla always encouter unexpected EOF, but google's version works well

    For easy to deployment, I use golang to re-implement my python's websocket client but always encouter the unexpected EOF error. Actually, my programs implement a pipeline of HTTP to websocket to HTTP, the websocket client keeps a long connection to a remote http server and proxy the remote request to the local http backend. The test method is using the apache httpd tool: ab -n 10000 -c 300 http://remote-http-domain/ Both the python client and the google's code.google.com/p/go.net/websocket are work well. Sorry about I'm an one-day-old golang newer and the next Monday I must commit my codes, so I just issue this problem and no further advice. Thanks for your consideration!

    opened by vegertar 17
  • Allocate write buffers only when needed

    Allocate write buffers only when needed

    A write buffer is allocated to the connection for the lifetime of the connection, but the buffer is only needed when the application is writing a message. Use the Go 1.3 sync.Pool type (https://code.google.com/p/go/source/detail?r=2d9fe00d6ce1) to get and put write buffers as needed.

    enhancement 
    opened by garyburd 17
  • Chat example.

    Chat example.

    in examples/chat/hub.go

    case m := <-h.broadcast:
                for c := range h.connections {
                    select {
                    case c.send <- m:
                    default:
                        close(c.send)
                        delete(h.connections, c)
                    }
                }
            }
    

    by default was necessary to have close and delete?

    I thought closing connection would be handled by unregister call? I am actually trying to understand the code so I can implement my own utility.

    Thank you for the support in advance.

    opened by mistercorea 16
  • nginx reverse proxy websocket, some connection disconnected with 1006

    nginx reverse proxy websocket, some connection disconnected with 1006

    i debug websocket service with ip:port, it runs well, this is important. but when i change to nginx for proxy websocket, it happens some connections just closed when request in (i watch the terminal),and the chrome,firefox console return readystate of 1006,but some other connected correctly.

    here is my code:

    nginx

    map $http_upgrade $connection_upgrade {
         default upgrade;
         ''      close;
    }
    
    upstream websocket {
        server 172.17.0.1:9099 weight=5 max_fails=3 fail_timeout=30s;
        keepalive 16;
    }
    
    server {
        listen 80;
        server_name mysite.com;
    
        location /ws {
             try_files $uri $uri/ @workman;
        }
    
        location @workman {
            # proxy_set_header HTTPS "on";
            proxy_pass http://websocket;
            proxy_read_timeout 300s;
            proxy_send_timeout 300s;
    
            proxy_http_version 1.1;
            proxy_set_header Host $http_host;
            proxy_set_header Scheme $scheme;
            proxy_set_header SERVER_PORT $server_port;
            proxy_set_header REMOTE_ADDR $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_redirect off;
        }
    
        location / {
            proxy_pass http://websocket;
            proxy_connect_timeout 300s;
    
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Scheme $scheme;
        }
    }
    
    bug 
    opened by weishuaiwang 0
  • Not able to get Ping message from server

    Not able to get Ping message from server

    Not able to get Ping message from server

    I am implementing client by using Gorilla Websocket. Server side is in Java.(Java server) Before I was not able to receive ping message from server.

    dial_connection.go:

    connection.SetPingHandler(func(appData string) error {
    	log.Info(appData)
    	connection.WriteMessage(websocket.PongMessage, []byte("ping"))
    	return connection.SetReadDeadline(time.Now().Add(handshakeWait))
    })
    

    After adding below method(readLoop), I am able to get the ping message from server. Getting from this link: https://pkg.go.dev/github.com/gorilla/websocket#hdr-Concurrency

    func readLoop(c *websocket.Conn) { for { if _, _, err := c.NextReader(); err != nil { c.Close() break } } }

    But the problem is that NextReader we can use once in the websocket. In another file ReceiveJobs.go already used NextReader to get the job payload from websocket. If I run the process, then I am not getting this job payload as one NextReader we can keep. some code snippet from ReceiveJob.go

    func ReceiveJobs() chan *models.WebsocketJobResponse { jobsChan := make(chan *models.WebsocketJobResponse)

    go func(conn *websocket.Conn, c chan *models.WebsocketJobResponse) {
    	for {
    		wsResp := &models.WebsocketJobResponse{}
    			_, r, err := conn.NextReader()
    

    Please guide me how can I resolve this issue.

    bug 
    opened by santanu22 10
  • Not able to get ping and pong message from server to go lang websocket client

    Not able to get ping and pong message from server to go lang websocket client

    Go lang client - https://github.com/gorilla/websocket From server-side we are sending the ping and pong message but the go lang client is not able to receive

    Tested with different websocket client and server Below are observations

    Java server and Node Js client = Ping woking Java server and Go, lang client, = Ping not working Node js server and Node Js client = Ping Working Node js server and Go lang client = Ping working

    The only issue we are facing is for the java server and go lang client Java server working with node js client and go lang client working with node js for a ping message

    Only issue between java server and go lang client as now we are facing for ping and pong message could you please help with this

    That would be very helpful

    Thanks

    question 
    opened by vitpravin 3
  • [question]

    [question]

    Describe the problem you're having

    A clear and concise description of what the bug is.

    I have a websocket between A and B hosts, and on A I setup a tcp server to listen on port 'a' and on B i launch a tcp connect to remote 'b'. and I want to transport/proxy tcp service from location A to remote 'b'

    I tried to use io.Copy to 'bridge' the tcp socket to/from the websocket websocket.Conn, and can not write to the websocket. it hangs on write.

    do you have any suggestions?

    Versions

    Go version: go version

    package version: run git rev-parse HEAD inside the repo

    in my go.mod, i have this version github.com/gorilla/websocket v1.4.2

    "Show me the code!"

    A minimal code snippet can be useful, otherwise we're left guessing!

    Hint: wrap it with backticks to format it

    this is A side of the code, meant to be one client connection at a time:

    func testWSSbridge(conn *websocket.Conn, local string) error {
    	listener, err := net.Listen("tcp", local)
    	if err != nil {
    		return err
    	}
    
    	for {
    		here, err := listener.Accept()
    		if err != nil {
    			return err
    		}
    		go func() {
    			_, reader, err := conn.NextReader()
    			if err != nil {
    				fmt.Printf("reader err %v\n", err)
    				return
    			}
    			io.Copy(here, reader)
    		}()
    		for {
    			writer, err := conn.NextWriter(websocket.BinaryMessage)
    			if err != nil {
    				fmt.Printf("writer err %v\n", err)
    				return err
    			}
    			defer writer.Close()
    			_, err = io.Copy(writer, here)
    		}
    	}
    }
    
    question 
    opened by naiming-zededa 12
  • [question] How to close a connect correctly?

    [question] How to close a connect correctly?

    Describe the problem you're having

    As I see, conn.Close() won't wait or send close message from/to peer. Does that mean if I only call Close() in server side to close a connnect, the peer will know nothing?

    Sounds bad. What's the best way to close a connenct?

    pls answer this on both two cases of closing connect initiatively and passively

    question 
    opened by suerta-git 6
  • [bug] slice bounds out of range while calling ReadMessage

    [bug] slice bounds out of range while calling ReadMessage

    Describe the bug

    A clear and concise description of what the bug is.

    It happens randomly, i think, as a traceback i got just a panic

    panic: runtime error: slice bounds out of range [:5228] with capacity 4096
    
    goroutine 316 [running]:
    bufio.(*Reader).Read(0xc0005b01e0, 0xc000eb1a55, 0x1ab, 0x1ab, 0x55, 0x0, 0x0)
            /usr/local/go/src/bufio/bufio.go:238 +0x3ba
    github.com/gorilla/websocket.(*messageReader).Read(0xc00000e010, 0xc000eb1a55, 0x1ab, 0x1ab, 0x55, 0x0, 0x0)
            /go/pkg/mod/github.com/gorilla/[email protected]/conn.go:1021 +0x1eb
    io.ReadAll(0x7fddc627f298, 0xc00000e010, 0x7fddc627f298, 0xc00000e010, 0x0, 0x0, 0x443)
            /usr/local/go/src/io/io.go:633 +0xdf
    io/ioutil.ReadAll(...)
            /usr/local/go/src/io/ioutil/ioutil.go:27
    github.com/gorilla/websocket.(*Conn).ReadMessage(0xc000096f20, 0x478, 0x500, 0xc00075d9cd, 0xb, 0xb, 0xffffffffffffffff)
            /go/pkg/mod/github.com/gorilla/[email protected]/conn.go:1068 +0x91
    main.(*Client).getReferal(0xc0004e68a0, 0xc000013b60, 0xc0000cffb0, 0x24, 0xc000459a70)
            /app/client.go:239 +0x325
    main.referalHandler(0xc000549600)
            /app/server.go:131 +0x16b
    github.com/fasthttp/router.(*Router).Handler(0xc0000d6000, 0xc000549600)
            /go/pkg/mod/github.com/fasthttp/[email protected]/router.go:414 +0x7c3
    github.com/valyala/fasthttp.(*Server).serveConn(0xc000080240, 0x7c5998, 0xc00000f700, 0x0, 0x0)
            /go/pkg/mod/github.com/valyala/[email protected]/server.go:2239 +0x14a2
    github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc000074a00, 0xc00044c160)
            /go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:223 +0xba
    github.com/valyala/fasthttp.(*workerPool).getCh.func1(0xc000074a00, 0xc00044c160, 0x6f5e20, 0xc00044c160)
            /go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:195 +0x35
    created by github.com/valyala/fasthttp.(*workerPool).getCh
            /go/pkg/mod/github.com/valyala/[email protected]/workerpool.go:194 +0x11f
    

    Versions

    Go version: go version package version: run git rev-parse HEAD inside the repo

    1.16, 1.4.2

    Steps to Reproduce

    How can the bug be triggered? I believe you should run concurrently app, that makes a lot of requests via websockets as a client

    Expected behavior

    What output or behaviour were you expecting instead?

    As minimum it must return error(from method ReadMessage i guess)

    Code Snippets

    A minimum viable code snippet can be useful! (use backticks to format it).

    bug 
    opened by Numenorean 1
  • [question]How can I distinguish the timeout reason

    [question]How can I distinguish the timeout reason

    Describe the problem you're having

    Every time server reads message from client, it will extend the read deadline 10s.However, if the network environment is so poor that a big buffer can`t be sent to server in 10s, and because of the big buffer server can't recieve pong, then the connect will be closed by server. So I am wondering that, could we distinguish that server didn't recieve pong because there is a big buffer being sent, or the connect has been shut down.

    Versions

    Go version: 1.14

    package version:1. 4. 2

    "Show me the code!"

    A minimal code snippet can be useful, otherwise we're left guessing!

    Hint: wrap it with backticks to format it

    question 
    opened by uzzz1 3
  • Static analysis : gosec high issue : G402 : TLS MinVersion too low.

    Static analysis : gosec high issue : G402 : TLS MinVersion too low.

    Issue:

    $ for mod in $(find . -name go.mod); do gosec -quiet -confidence high -severity high $(dirname $mod) || rc=1 ; done Results: [github.com/gorilla/websocket/client_clone.go:13] - G402 (CWE-295): TLS MinVersion too low. (Confidence: HIGH, Severity: HIGH) 12: if cfg == nil { 13: return &tls.Config{} 14: } Summary: Gosec : dev Files : 15 Lines : 3475 Nosec : 0 Issues : 1

    opened by Momotoculteur 2
  • In some windows systems, the upgrade protocol will block

    In some windows systems, the upgrade protocol will block

    Versions

    Go version: go version go1.16.2 linux/amd64 package version: run github.com/gorilla/websocket v1.4.2

    in windows,upgrade will keep blocking

    Steps to Reproduce

    How can the bug be triggered?

    connect to websocket

    Expected behavior

    What output or behaviour were you expecting instead?

    in my ubuntu system,connect and upgrade is normal

    Code Snippets

    A minimum viable code snippet can be useful! (use backticks to format it).

    func StartWsServer(hub *Hub, w http.ResponseWriter, r *http.Request) {
    	if r.URL.Path != "/channel" {
    		http.Error(w, "NotFound", http.StatusNotFound)
    		return
    	}
    	if r.Method != http.MethodGet {
    		http.Error(w, "MethodNotAllowed", http.StatusMethodNotAllowed)
    		return
    	}
    	token := r.Header.Get("token")
    	claims, err := infs.ParseToken(token)
    	if err != nil {
    		http.Error(w, "Unauthorized", http.StatusUnauthorized)
    		return
    	}
    	conn := Repos.PoolRedis.GetPool().Get()
    	defer conn.Close()
    	rt, err := redis.String(conn.Do("GET", fmt.Sprintf("user:%v:token", claims.Id)))
    	if err != nil {
    		http.Error(w, "Unauthorized", http.StatusUnauthorized)
    		return
    	}
    	if rt != token {
    		http.Error(w, "Unauthorized", http.StatusUnauthorized)
    		return
    	}
            // here will be blocked forever
    	ws, err := upgrader.Upgrade(w, r, nil)
    	if err != nil {
    		log.Error(err)
    		return
    	}
    	client := &Client{
    		hub:      hub,
    		conn:     ws,
    		id:       claims.Id,
    		token:    token,
    		state:    stateOnly,
    		shutdown: make(chan struct{}),
    		send:     make(chan *pb.ServerMsg, defaultSendChanBufSize),
    		group:    make(map[int64]int64),
    	}
    	hub.register <- client
    	log.Info("websocket client started ", client.id, ws.RemoteAddr())
    	go client.write()
    	go client.read()
    	go client.event()
    }
    
    bug 
    opened by 19byte 3
  • how to set timeout

    how to set timeout

    How do I set TLS handshake timeout? Does HandshakeTimeout refer to websocket HandshakeTimeout? Does it include the TCP three-way handshake and the TLS handshake?

    question 
    opened by caleb-letsgo 1
Releases(v1.4.2)
  • v1.4.2(Mar 19, 2020)

    v1.4.2 is a minor maintenance release, with minor fixes to examples, documentation, and internals.

    Note: We are still looking for proactive maintainer(s) and issue triagers. Thanks to all who contributed to this release with either PRs or reviews - especially @srybacki for the ongoing efforts here.

    CHANGELOG

    • build: clean up go.sum (#584) @elithrar
    • Fix typo. (#568) @jongillham
    • Duration order consistency when multiplying number by time unit (#570) @maxifom
    • echo example: handle received messages as text, not HTML (#563) @srybacki
    • Use empty struct to protect writing (#566) @ferhatelmas
    • input autofocus (#564) @codenoid
    • Fix a couple of small typos (#567) @johnernaut
    • minor typo (#583) @dbaker-rh
    • Changed the link of API references to pkg.go.dev (#577) @thearyanahmed
    Source code(tar.gz)
    Source code(zip)
  • v1.4.1(Aug 24, 2019)

    Notable Changes

    ⚠️ This release fixes a potential denial-of-service (DoS) vector in gorilla/websocket, and we recommend that all users upgrade to this version (v1.4.1) or later

    The vulnerability could allow an attacker to consume excessive amounts of memory on the server by bypassing read limits, and potentially cause the server to go out-of-memory (OOM).

    See the published security advisory for more details.

    Credit to Max Justicz (https://justi.cz/) for discovering and reporting this, as well as providing a robust PoC and review.

    CHANGELOG

    c3e18be Create release-drafter.yml (#538) 5b740c2 Read Limit Fix (#537) 7e9819d fix typos (#532) ae1634f Create CircleCI config.yml (#519) 80c2d40 fix autobahn test suite link (#503) 6a67f44 remove redundant err!=nil check in conn.go Close method (#505) 0ec3d1b Fix typo 856ca61 Add buffer commentary 7c8e298 Add support for go-module 8ab6030 Add JoinMessages 95ba29e Updated autobahn test suite URL 483fb8d Add "in bytes" to sizes in documentation 76e4896 Fix formatting problem in the docs. (#435) a51a35a Improve header parsing code 3130e8d Return write buffer to pool on write error (#427) cdd40f5 Add comprehensive host test (#429)

    Source code(tar.gz)
    Source code(zip)
  • v1.4.0(Sep 2, 2018)

    Note: This release drops support for Go versions prior to v1.7.

    This release adds a new DialContext function, which supports cancellation via the context.Context.

    CHANGELOG:

    66b9c49 Move context to first parameter in DialContext a9dd6e8 miscellaneous cleanup ceae452 Add context in the Dialer b378cae Add write buffer pooling 5fb9417 drop Go versions prior to 1.7 in CI

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Aug 21, 2018)

    Note: This will be the last release that supports Go 1.6 and earlier. Go 1.6 was released in February 2016. Features may be backported upon request, but we recommend users build their applications with the latest versions of Go wherever possible.

    CHANGELOG

    3ff3320 Improve server subprotocol documentation 5ed622c Update LICENSE file to reflect Google employee contributions. c17c80c Merge pull request #385 from dottyjones/master badcf87 Improve names in handshake deadline test f90b62c Add test for handshake deadline 21ab95f Modify headers to match case used in RFC examples cd94665 Minor fixes in comments eb92580 Use net.Buffers to write multiple slices to connection 4835f71 Improve client default timeout code 8c40c0b Bump default handshake timetout to 45 seconds 196b8d0 Add a default handshake timeout of 5 seconds e426f23 Sec-WebSocket-Protocol is capitalize instead of canonical 6656ddc add newline and remove extra space 0647012 Modify http status code to variable f37d158 Travis config: add Go 1.10.x, revert 1.4.x to 1.4 2967b10 Use latest patch releases of Go 8fbc40b Simplify echo example client (#349) 4ac9097 Improve control message handler doc 91f589d Improve check origin documentation 292fd08 Replace "frame" with "message" in documentation 58729a2 Don't log 1006 error in chat example d965e9a Handle no status in FormatCloseMessage cdedf21 examples/chat/client.go: avoid allocating []byte{} for PingMessage (#312) c55883f Add parseExtensions test case (#310) b89020e Add SOCKS5 support 8c6cfd4 Improve bad handshake error text 2b58522 update README.md b648f20 Use ASCII case folding in same origin test 23059f2 Update with gofmt on tip 447c2df Compare request header tokens with ASCII case folding aa5ed01 Improve control message handling documentation 7ca4275 More consistent error handling in doc 3da6ca0 Simplify and fix spelling errors in test files 71fa72d Replace parseURL() with net/url.Parse() (#290) f918560 Improve NextWriter documentation c908dc8 Typo fix 4201258 Merge pull request #286 from alaingilbert/patch-1 5755884 Add missing html tag in example/echo 6f34763 Add Go 1.9 to Travis config a69d9f6 Merge branch 'updoc' 92f772e Misc cleanup f4f69d2 implementing (some of) @garyburd's suggestions 462d5c5 Merge pull request #261 from kybin/master 1d375d5 distinguish Upgrader.Upgrade from Upgrade 7a8dacf doc: use ":=" when check error for conn.WriteMessage

    Source code(tar.gz)
    Source code(zip)
  • v1.2.0(Jun 24, 2017)

    v1.2.0 addresses client compression bugs, improves error messages surrounding HTTP Upgrade requests, and improves the safety around how bytes were masked.

    CHANGELOG

    ea4d1f6 Reduce memory used in chat example a91eba7 Merge pull request #230 from FZambia/fix_client_compression 8dc1cf9 enable client compression based on response header b258b4f Use bufio.Writer returned from hijack in upgrade 4873052 Fix formatting. 286b5c9 Use bufio.Reader returned from hijack in upgrade 3f3e394 Update cloneTLSConfig to use Go 1.8 Config.Clone method 9acaa68 Add Go 1.8 to Travis config 5ade364 Improve examples 804cb60 Prepared Messages (#211) 9bc973a Change text/template to html/template in the examples c36f2fe Merge pull request #210 from nobuf/nobuf/update-doc-about-compression 1025138 Add code snippet for EnableCompression in doc.go, change EnableWriteCompression()'s parameter to false since enableWriteCompression is true by default. 4e4c8d0 Merge pull request #208 from FZambia/flate_write_pool_fix ac61189 remove test as HuffmanOnly compression level not defined in Go < 1.7 eb45753 fix flate write pool size to work with best compression 0674c7c Improve upgrade error messages 2257eda Fix compile error on Go < 1.6 522f286 Fix to compile on Go < 1.6 b0dc455 Change default and add API for compression level bb547c6 Improve SetXHandler documentation 561ac01 Merge pull request #205 from FZambia/compression_benchmarks 34e0535 benchmarks for write with compression enabled/disabled 1763434 Update compression documentation adf16b3 Add safe maskBytes 5ddbd28 Merge branch 'compress' 6c51b25 Compression improvements 404e6b1 Merge pull request #199 from AndrienkoAleksandr/master 0e7877a Fix up README.md for command example. 2db2f66 pool flate readers

    Source code(tar.gz)
    Source code(zip)
  • v1.1.0(Dec 22, 2016)

Owner
Gorilla Web Toolkit
Gorilla is a web toolkit for the Go programming language that provides useful, composable packages for writing HTTP-based applications.
Gorilla Web Toolkit
A fast, well-tested and widely used WebSocket implementation for Go.

Gorilla WebSocket Gorilla WebSocket is a Go implementation of the WebSocket protocol. Documentation API Reference Chat example Command example Client

Gorilla Web Toolkit 15.5k Sep 17, 2021
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

websocketd websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSoc

Joe Walnes 15.7k Sep 14, 2021
:notes: Minimalist websocket framework for Go

melody ?? Minimalist websocket framework for Go. Melody is websocket framework based on github.com/gorilla/websocket that abstracts away the tedious p

Ola 2.2k Sep 20, 2021
Go client for an OBS WebSockets server

goobs It's a Go client for Palakis/obs-websocket, allowing us to interact with OBS Studio via Go. disclaimer This project is still a work-in-progress.

Andrey Kaipov 24 Sep 12, 2021
Tiny WebSocket library for Go.

RFC6455 WebSocket implementation in Go.

Sergey Kamardin 4.1k Sep 22, 2021
websocket消息推送服务

balloons-websocket 用于构建实时应用程序的基础架构和API,balloons提供了最好的基础架构和API,以大规模地提供实时体验。向最终用户提供快速稳定的实时消息。让我们处理实时消息传递的复杂性,以便您可以专注于代码。 balloons的实时API向开发人员公开了整个balloon

null 11 Apr 4, 2021
gatews - Gate.io WebSocket SDK

gatews - Gate.io WebSocket SDK gatews provides new Gate.io WebSocket V4 implementations. It is intended to work along with gateapi-* series to provide

gate.io 19 Aug 29, 2021
Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Go Example for TurboStreams over WebSockets Simple example for using Turbos Streams in Go with the Gorilla WebSocket toolkit.

Jan Stamer 16 Jun 29, 2021
run shell scripts by websocket with go lauguage

go_shell_socket run shell scripts by websocket with go lauguage Usage pull project get gin and websocket with go get config config.json file build it

soQ 18 Jun 3, 2021
proxy your traffic through CDN using websocket

go-cdn2proxy proxy your traffic through CDN using websocket what does it do example server client thanks what does it do you can use this as a library

jm33-ng 31 Sep 9, 2021
WebSocket Command Line Client written in Go

ws-cli WebSocket Command Line Client written in Go Installation go get github.com/kseo/ws-cli Usage $ ws-cli -url ws://echo.websocket.org connected (

Kwang Yul Seo 16 Jun 13, 2021
A modern, fast and scalable websocket framework with elegant API written in Go

About neffos Neffos is a cross-platform real-time framework with expressive, elegant API written in Go. Neffos takes the pain out of development by ea

Gerasimos (Makis) Maropoulos 367 Sep 16, 2021
Terminal on browser via websocket

Terminal on browser via websocket. Supportted OS Linux Mac

skanehira 122 Aug 27, 2021
simpleChatInGo - This is a simple chat that i made for fun asnd learn more about websocket

simpleChatInGo This is a simple chat that i made for fun asnd learn more about websocket deploy For deploy this you only need to run the command : $ d

ranon rat 6 Aug 7, 2021
Chat bots (& more) for Zoom by figuring out their websocket protocol

zoomer - Bot library for Zoom meetings Good bot support is part of what makes Discord so nice to use. Unfortunately, the official Zoom API is basicall

Christopher Tarry 41 Sep 2, 2021
go-socket.io is library an implementation of Socket.IO in Golang

go-socket.io is library an implementation of Socket.IO in Golang, which is a realtime application framework.

Googol Lee 4.3k Sep 24, 2021
a simple shitty project for learn more about websockets

video-transmission A simple shitty project for learn more about websockets. For run this you only need to have docker in your computer and then execut

ranon rat 5 Jul 14, 2021