Open adrpino opened 6 years ago
Hi, to be honest I have no idea. It's a bit more alive at official fork here https://github.com/binance-exchange/go-binance/ - at least PR-wise.
I haven't seen or used the APIs for a while now but looking at the error it looks that something with Websocket APIs really changed. I'll keep this open just in case I got back to this some day.
Got that error, too. Issues are not activated in the fork project.
This error/issue happens when goroutine exitHandler sends message 1 second.
case t := <-ticker.C:
err := c.WriteMessage(websocket.TextMessage, []byte(t.String()))
if err != nil {
level.Error(as.Logger).Log("wsWrite", err)
return
}
It works fine without "send" message
@sinyakinilya How to fix?
@rootpd @adrpino @sinyakinilya @Betazoid
If I delete service_websocket.go
line 414~419, it works fine.
But I do not know what error will occur since I deleted that part of codes.
I use conn.NextWriter instead of conn.WriteMessage to write msg and it works well.
w, err := conn.NextWriter(websocket.TextMessage)
if err != nil {
logger.Error(err.Error())
return
}
w.Write([]byte(msg))
I use conn.NextWriter instead of conn.WriteMessage to write msg and it works well.
w, err := conn.NextWriter(websocket.TextMessage) if err != nil { logger.Error(err.Error()) return } w.Write([]byte(msg))
Has anyone fixed this issue? I tried using the fix from @crlrfzj but it doesn't work.
exitHandler in service_websocket.go is sending unsollicited text message to server every second.
I do not see the need for sending this message every second.
Binance api docs says :
The websocket server will send a ping frame every 3 minutes. If the websocket server does not receive a pong frame back from the connection within a 10 minute period, the connection will be disconnected. Unsolicited pong frames are allowed
But gorilla websocket handle PING/PONG frames on its own.
Two solutions that worked for me :
err := c.WriteMessage(websocket.TextMessage, []byte("--heartbeat--"))
if err != nil {
level.Error(as.Logger).Log("wsWrite", err)
return
}
websocket.TextMessage
by websocket.PongMessage
as unsolicited pong frames are allowedRemove ticker is a better solution IMO. I created a PR for the fix
Removed it. I support this repo here: https://github.com/filinvadim/go-binance
Update: i have special wss client for echange wss endpoints - https://github.com/filinvadim/stubborn. Welcome!
I am attempting to run the example and when reading data from the websocket I get the following error:
Has the API changed in some way and some adaptations are required? I remember using this package months ago and worked like a bliss.
If you need help with it I'm willing to give a hand