You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I seem to have an issue with reconnecting the socket in the Close event (DefaultWebSocketClient.Close) . If I disconnect by executing Cancel on the token service and then reconnect with another button, the service reconnects successfully. But if I try and reconnect in the close event the AggregateTradeWebSocketClient.AggregateTrade event stop firing. The socket is transmitting data, however, because I can see aggregate trade update messages in the DefaultWebSocketClient.Message event handler TryConnectOnClose.zip
The best way I can demonstrate is with a sample application. See attached.
The text was updated successfully, but these errors were encountered:
@rakewell unfortunately I did mention the Close event could be used in that way (although I did not recommend it).... Regardless, you can't reconnect on the Close event Thread. Assuming you are awaiting the call, that will prevent the Close event handler from returning.
@rakewell, I appreciate the simplicity of you giving me the code to try in order to demonstrate the issue and I have no reason to believe you have any ill intentions. However, I still have to worry about security. So, sorry, I did not look at or run the code you provided. And yes, the fact you are running code I provide is not lost on me... if the code were visible on GitHub I could at least look at it without worry.
@sonvister thanks for your reply and I understand you not wanting to run the project. At this point you understand the problem so there's no need to post the code.
I managed to reconnect the socket on another thread using: Dim cnnTask = Task.Run(Async Sub() ConnectSocket())
This allowed the socket to reconnect and continue streaming successfully.
I am also trying to get the RetryTaskController to work but am having problems. Here is the following code that I am using to run the controller:
`
Me.UnSubscibeAllTradeUpdatesManaged()
Me.m_BinanceAggregateTradeSocketCancel = New CancellationTokenSource
For Each assRow In Me.m_AssetPrices
Me.m_BinanceAggregateTradeSocket.Subscribe(assRow.Key)
Next
m_SocketConnectionRetryTaskController = New RetryTaskController
Using m_SocketConnectionRetryTaskController
m_SocketConnectionRetryTaskController.Begin(Function() As Task
Return m_BinanceAggregateTradeSocket.StreamAsync(m_BinanceAggregateTradeSocketCancel.Token)
End Function)
End Using`
When the open event is called:
`
Private Sub m_BinanceSocketTradeStreamClient_Open(sender As Object, e As EventArgs) Handles m_BinanceTradeSocketStreamClient.Open
Try
If Me.InvokeRequired Then
Me.Invoke(New Action(Of Object, EventArgs)(AddressOf Me.m_BinanceSocketTradeStreamClient_Open), sender, e)
Else
Me.TradeSocketStatusGroup.BackColor = Color.LightGreen
Me.TradeSocketStatusGroup.ForeColor = Color.Black
End If
Catch ex As Exception
HandleSocketApiException(ex)
End Try
End Sub`
It seems to lock the UI thread on the line: Me.Invoke(New Action(Of Object, EventArgs)(AddressOf Me.m_BinanceSocketTradeStreamClient_Open), sender, e)
Does the retry task controller lock the UI thread while it is in operation? Is there any way I can achieve a re-connection with the RetryTaskController without locking the UI Thread?
Hello,
I seem to have an issue with reconnecting the socket in the Close event (DefaultWebSocketClient.Close) . If I disconnect by executing Cancel on the token service and then reconnect with another button, the service reconnects successfully. But if I try and reconnect in the close event the AggregateTradeWebSocketClient.AggregateTrade event stop firing. The socket is transmitting data, however, because I can see aggregate trade update messages in the DefaultWebSocketClient.Message event handler
TryConnectOnClose.zip
The best way I can demonstrate is with a sample application. See attached.
The text was updated successfully, but these errors were encountered: