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
When a handler is set to return true, it seems it will remove the function and the websocket will unsubscribe to channel if no more handler for same channel.
But if the websocket is closed right away after the handler execution, the unsubscription to channel will fail and results to panic.
conf, err := sdk.NewConfig([]string{"http://csddev1.xpxsirius.io:3000", "http://csddev2.xpxsirius.io:3000"}, sdk.PrivateTest, sdk.WebsocketReconnectionDefaultTimeout)
if err != nil {
panic(err)
}
ctx, cancel := context.WithTimeout(context.TODO(), time.Second*30)
//defer cancel()
wsClient, err := websocket.NewClient(ctx, conf)
if err != nil {
panic(err)
}
go wsClient.Listen()
address, err := sdk.NewAddressFromRaw("WAFSWQIF2UBLBHOFOYMIQJXZKRSTNONZIM6VYAZT")
if err != nil {
panic(err)
}
txn, err := sdk.NewTransferTransaction(
sdk.NewDeadline(time.Hour),
address,
[]*sdk.Mosaic{},
sdk.NewPlainMessage(fmt.Sprintf("hi there %d", rand.Int())),
sdk.PrivateTest,
)
if err != nil {
panic(err)
}
acct, err := sdk.NewAccountFromPrivateKey("b007b006c2178a8819c6b38dd3b49db1c2170483fdfcff21656f071c7541b5a9", sdk.PrivateTest)
if err != nil {
panic(err)
}
signedTxn, err := acct.Sign(txn)
if err != nil {
panic(err)
}
var wg sync.WaitGroup
wg.Add(1)
err = wsClient.AddUnconfirmedAddedHandlers(address, func(txn sdk.Transaction) bool {
fmt.Println("FOUND", txn.GetAbstractTransaction().Hash.String())
if txn.GetAbstractTransaction().Hash.String() == signedTxn.Hash.String() {
fmt.Println("FOUND HASH IT ON UNCONFIRMED", txn.GetAbstractTransaction().Hash.String())
wg.Done()
// ISSUE
return true
}
return false
})
if err != nil {
panic(err)
}
client := sdk.NewClient(nil, conf)
_, err = client.Transaction.Announce(context.Background(), signedTxn)
fmt.Println("ANNOUNCED", signedTxn.Hash)
if err != nil {
panic(err)
}
wg.Wait()
cancel()
The text was updated successfully, but these errors were encountered:
When a handler is set to return true, it seems it will remove the function and the websocket will unsubscribe to channel if no more handler for same channel.
But if the websocket is closed right away after the handler execution, the unsubscription to channel will fail and results to panic.
The text was updated successfully, but these errors were encountered: