FAQ
Did you ever get a solution to this? I have a similar situation with
Send/Write on a websocket not giving an
error when the client is disconnected.
On Thursday, 21 June 2012 13:15:42 UTC+1, zeroc8 wrote:

I know for TCP connections writing to a broken socket (lost connection) is
one of the fastest ways to realize a client has disconnected. This message
will also have the side benefit of helping the client keep their connection
open longer because some network systems may terminate a connection if no
data has been sent/received in a given amount of time.
Well, that's the initial approach I wanted to take. However, this doesn't
seem to work. Here's what I'm doing:

for id, subscr := range subscribers {
msg.To = id

subscr.ws.SetWriteDeadline(time.Now().Add(300*time.Millisecond))
err := websocket.JSON.Send(subscr.ws,msg)

if err != nil {
log.Println("Cannot deliver connection checker
msg:",msg,err)
} else {
log.Println("Connection checked")
}
}

I thought that I would an io/timeout error here after pulling the cable,
but the Send method never returns an error.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 5, '14 at 7:51p
activeMar 5, '14 at 7:51p
posts1
users1
websitegolang.org

1 user in discussion

Aiden: 1 post

People

Translate

site design / logo © 2021 Grokbase