rsms / gotalk Goto Github PK
View Code? Open in Web Editor NEWAsync peer communication protocol & library
License: MIT License
Async peer communication protocol & library
License: MIT License
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
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?
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?
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
This happens on windows amd64, because of this file
https://github.com/rsms/gotalk/blob/master/js/gotalk.js.go
Is there any way to avoid large amount of string concatenations? According to @bradfitz it's the main problem, similar bug https://code.google.com/p/go/issues/detail?id=8240#c2
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?
Please add an example for establishing encrypted connections. A quite important feature nowadays.
You are welcome to include my script if you use TLS:
https://gist.github.com/wmark/c758ce1c2b8222afd69d
I would like to have the capability to cluster to scale this solution horizontally... Any Plans?
Why requestid is 3 bytes? Isn't it small a bit? Isn't 4 byte more suitable?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.