Giter Club home page Giter Club logo

Comments (3)

mofadeyunduo avatar mofadeyunduo commented on May 24, 2024 6

我改了下他上面的问题,并且魔改了一些东西,Socket.IO 2.x 也可以使用,可以参考 go-socket.io-client,有问题提 Issue

from go-socket.io-client.

mofadeyunduo avatar mofadeyunduo commented on May 24, 2024
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.

hlbbt avatar hlbbt commented on May 24, 2024

我改了下他上面的问题,并且魔改了一些东西,Socket.IO 2.x 也可以使用,可以参考 go-socket.io-client,有问题提 Issue

请问基于https地址的socket是否支持,我自己测试是不支持的。
image
显示超时,我使用nodejs是可以实现的,基于socket.io 1.7.4版本

from go-socket.io-client.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.