Comments (3)
我改了下他上面的问题,并且魔改了一些东西,Socket.IO 2.x 也可以使用,可以参考 go-socket.io-client,有问题提 Issue
from go-socket.io-client.
func (c *clientConn) pingLoop() {
lastPing := time.Now()
lastTry := lastPing
for {
now := time.Now()
pingDiff := now.Sub(lastPing)
tryDiff := now.Sub(lastTry)
select {
case ok := <-c.pingChan:
if !ok {
return
}
fmt.Println("ping chan receive data")
lastPing = time.Now()
lastTry = lastPing
case <-time.After(c.pingInterval - tryDiff):
fmt.Println("ping again")
c.writerLocker.Lock()
if w, _ := c.getCurrent().NextWriter(message.MessageText, parser.PING); w != nil {
writer := newConnWriter(w, &c.writerLocker)
writer.Close()
} else {
c.writerLocker.Unlock()
}
lastTry = time.Now()
}
case <-time.After(c.pingTimeout - pingDiff):
c.Close()
return
}
}
}
Socket.IO 默认 pingInterval 为 25s,pingTimeout 5s,如果 pingInterval > pingTimeout 会导致强制销毁 Socket.IO 链接,我觉得这个是有问题的
from go-socket.io-client.
我改了下他上面的问题,并且魔改了一些东西,Socket.IO 2.x 也可以使用,可以参考 go-socket.io-client,有问题提 Issue
请问基于https地址的socket是否支持,我自己测试是不支持的。
显示超时,我使用nodejs是可以实现的,基于socket.io 1.7.4版本
from go-socket.io-client.
Related Issues (16)
- 未知原因在源码中`pack, err = c.getCurrent().NextReader()`处出现问题 HOT 3
- go-socket.io-client 连接nodejs socket.io HOT 1
- reconnect after disconnect HOT 1
- namespace如何使用 HOT 1
- Attachment?
- 请问客户端如何主动断开连接
- How add header for socket.io? HOT 2
- Invalid Input when creating new client HOT 4
- How can we pass auth params to authenticate the client?
- 不支持 EIO=4,指定 EIO=4 当创建连接时报错:Invalid Input
- error:websocket: bad handshake
- Acknowledgement callback not working because of Line 148: client.go
- 0.9.x
- Intermittent connection failures HOT 1
- Namespace HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-socket.io-client.