Vbnet handshake problem
Hello, i'm developing vb.net application, i have a problem even if the command connect give me result ok, when i send data i got always you must send data only if websocket is open...
Could you help me:?
Private websocket As WebSocket4Net.WebSocket
Sub Main()
WebSocket = New WebSocket4Net.WebSocket("wss://ws.binaryws.com/websockets/v3") AddHandler WebSocket.Opened, Sub(s, e) socketOpened(s, e) AddHandler WebSocket.Error, Sub(s, e) socketError(s, e) AddHandler WebSocket.Closed, Sub(s, e) socketClosed(s, e) AddHandler WebSocket.MessageReceived, Sub(s, e) socketMessage(s, e) AddHandler WebSocket.DataReceived, Sub(s, e) socketDataReceived(s, e) websocket.Open() Console.WriteLine(websocket.State) websocket.Send("{""ticks_history"":""R_50"",""end"":""latest"",""count"":10}")
End Sub
Sub socketClosed(s As Object, e As EventArgs)
End Sub
Sub socketError(s As Object, e As SuperSocket.ClientEngine.ErrorEventArgs)
MsgBox(e.Exception.ToString
)
End Sub
Sub socketMessage(s As Object, e As WebSocket4Net.MessageReceivedEventArgs)
MsgBox(e.Message)
End Sub
Sub socketDataReceived(ss As Object, e As WebSocket4Net.DataReceivedEventArgs)
MsgBox(e.Data)
End Sub
Comments
Hello,
i update my code but the result it's the same... the socket will not open...
@Raunak Would appreciate if you could assist to check for this query, Thank you
thanks Brian, but my problem is after connect command... the socket will not open..
As per the screenshot, you are sending
ping
just afterwebsocket.open
that will not work as websocket is not opened yet. need to move that ping insocketMessage
I get it. When you call Websocket.Open it asks the websocket to open, but doesn't wait for the socket to open. That is why the ping request fails.