Giter Site home page Giter Site logo

rsms / gotalk Goto Github PK

View Code? Open in Web Editor NEW
1.2K 39.0 76.0 3.38 MB

Async peer communication protocol & library

License: MIT License

Go 68.71% JavaScript 26.99% Makefile 2.39% HTML 0.23% Shell 1.68%
protocol-communication streaming websocket golang

gotalk's Issues

Heartbeat panics when connection is lost

Hi there, I am using gotalk with linux devices and we sometimes reboot these devices, and at one time we encountered an error with panic in app

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xa64872]

goroutine 3183863 [running]:
github.com/rsms/gotalk.(*Sock).SendHeartbeat(0xc007e9d140, 0xc03d834c1b, 0xc001cd0dd0, 0x10, 0x10, 0x0, 0x0)
        /Users/berkcan/go/pkg/mod/github.com/rsms/[email protected]/sock.go:662 +0xd2
github.com/rsms/gotalk.(*Sock).sendHeartbeats(0xc007e9d140, 0xc0050b6720)
        /Users/berkcan/go/pkg/mod/github.com/rsms/[email protected]/sock.go:643 +0xb5
created by github.com/rsms/gotalk.(*Sock).Read
        /Users/berkcan/go/pkg/mod/github.com/rsms/[email protected]/sock.go:700 +0x8c5

Is there a way to recover from panic

Gotalk connection close is called after 30 seconds

Hi everyone,
I have server side

gotalk.Handle("connect", func(req model.SubscribeMachineReq) (model.SubscribeMachineReq, error) {
		log.Println("connect received")
		return req, nil
	})
	if err := gotalk.Serve("tcp", "localhost:1234",func (s *gotalk.Sock){}); err != nil {
		log.Println(err.Error())
	}

as well as client side

sock, err := gotalk.Connect("tcp", "localhost:1234")
	if err != nil {
		log.Println("Couldnt connect to streamer 1")
		time.Sleep(time.Second * 10)
		return
	}
	log.Println("Connected to streamer")
	sock.CloseHandler = func(socket *gotalk.Sock, code int) {
		Socket=nil
		log.Println(fmt.Sprintf("Streamer connection is broken with code:%d, retrying...",code))
		time.Sleep(time.Second * 10)
	}

The function I've set as CloseHandler is called after exacly 30 seconds of connection, why is that?

Protocol test suite

I am writing a Swift client for GoTalk and it would be excellent if there were a protocol test suite available. I have the base protocol written, but verifying correctness is a matter of trial and error.

I may tackle this myself, but thought I'd file an issue to gather thoughts first.

I imagined a data-driven suite would probably be most useful for different language implementations. Perhaps something where an implementation can load a JSON file (or whatever) and playback simulated communications with a server or client.

Thoughts?

Possible Notification discrepancy

I noticed the following example:

+---------------------- Notification
|              +--------- type        "chat message"
|              |       +- payloadSize 50
|              |       |
n00cchat message00000032{"message":"Hi","from":"nthn","chat_room":"gonuts"}

With the following definition:

Notification    = "n" type payload

type            = text3
payload         = payloadSize payloadData?
payloadSize     = hexUInt8
payloadData     = <byte>{payloadSize}

text3           = text3Size text3Value
text3Size       = hexUInt3
text3Value      = <<byte>{text3Size} as utf8 text>

It looks like the text3 isn't documented in the example. Should be:

+---------------------- Notification
|  +--------------------- text3Size   12
|  |           +--------- type        "chat message"
|  |           |       +- payloadSize 50
|  |           |       |
n00cchat message00000032{"message":"Hi","from":"nthn","chat_room":"gonuts"}

This tripped me up a little when working on a quick and dirty Python implementation: https://github.com/gtaylor/python-gotalk

[gotalk.js] Uncaught ReferenceError: s is not defined

when using gotalk.js in browser side, Sock.notify and Sock.stopSendingHeartbeats all have the error message:Uncaught ReferenceError: s is not defined. When I'm looking through the code I found this in gotalk/index.js:

Sock.prototype.stopSendingHeartbeats = function() {
  clearTimeout(s._sendHeartbeatsTimer);
};

and this for Sock.bufferNotify

Sock.prototype.bufferNotify = function(name, buf) {
  s.sendMsg(protocol.MsgTypeNotification, null, name, 0, buf);
}

is this right?

RequestId

Why requestid is 3 bytes? Isn't it small a bit? Isn't 4 byte more suitable?

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.