This is a Socket.IO library for Go.
- When doing a server side emit, ack callback cannot be given.
- Dynamic namespaces feature is not supported.
The least supported Socket.IO version is 3.0. If you have an older version of Socket.IO in your other projects, please consider upgrading your dependencies.
JavaScript Socket.IO version | Socket.IO protocol revision | Engine.IO protocol revision | socket.io-go version |
---|---|---|---|
0.9.x | 1, 2 | 1, 2 | Not supported |
1.x, 2.x | 3, 4 | 3 | Not supported |
3.x, 4.x | 5 | 4 | 0.x |
While writing this package, I noticed that Socket.IO is a very complicated and bloated library. As of writing (2024), WebSocket is a very feasible option. In my opinion, one should prefer to use WebSocket if features specific to Socket.IO (e.g. timeout, reconnection, adapter) are not needed.
Try reducing pingInterval and pingTimeout.
See the examples directory for the chat example. See pkg.go.dev for documentation.
The names below should not be used as event names (Emit
and OnEvent
). Otherwise, panic will occur.
connect
connect_error
disconnect
disconnecting
open
error
ping
close
reconnect
reconnect_attempt
reconnect_error
reconnect_failed
If you are a contributor, please see: Developing a Transport
JSON serialization is highly customizable. Under the parser/json/serializer
directory there are different packages for JSON serialization:
Name | Description | Usage |
---|---|---|
stdjson |
stdlib's encoding/json . This is the default serializer. |
README.md |
go-json | README.md | |
sonic | README.md | |
fast |
Conditionally uses sonic or go-json. | README.md |
Contributions are very welcome. Please read this page.