centrifuge.Rpc Always timeout
Closed this issue · 9 comments
r.socket = centrifuge.New(config.SocketUrl, centrifuge.DefaultConfig())
_, err := r.socket.RPC(dataBytes)
if err != nil {
fmt.Println(err)
}
err Always timeout
but service can Receive message
@ZhuRongJian hi, just checked this locally and can't reproduce – I receive a Not Available
error if RPC proxy is not registered on server side and a proper response if RPC is registered. Check out your timeout configuration.
@FZambia I found out the problem. When I write RPC in OnMessage, it will time out
@ZhuRongJian yeah, just made an example on how to deal with this at moment.
The reason is that at moment registered callbacks called from the same goroutine that reads from WebSocket. Since OnMessage callback blocked on RPC call then reading loop can not proceed to read RPC reply from server. Need to think what is the best way to deal with this.
@FZambia Hi,I try to modify the client.reader method to solve this problem, but I don't know what the impact will be.
@Larry-Dev hi, this should solve a case, but this is a backwards incompatible change and can lead to races in existing user code since registered callbacks will be called from different goroutines. Also I believe this can cause ordering problems in some cases.
@FZambia thx,i see. i use go xxxx()
in my business method.
OnMessage(.....){
go test(xxx)
}
@Larry-Dev what do you think about #31 ? This should resolve requirement to use separate goroutine inside handler.
@FZambia 👍,I use your code to check this problem is correct, I think very good.Thanks.
Released with v0.4.0