Comments (5)
Currently no. You can detect the socket closing using the BinanceStreamSubscription object returned when subscribing, but you'll just have to manually resubscribe. Might be a good addition though.
from binance.net.
Ok thanks
from binance.net.
I've been using things like this in my console apps:
public static void Subscribe(bool autoReconnect, params string[] symbols)
{
foreach (var symbol in symbols)
{
Console.Write(string.Concat("Subscribing to ", symbol, " ..."));
var sub = _socket.SubscribeToKlineStream(symbol, Interval, HandleIncomingKline);
sub.Data.Closed += () => { Sub_Closed(symbol, autoReconnect); };
sub.Data.Error += (e) => { Sub_Error(symbol, e); };
if(!sub.Success)
{
Console.WriteLine(string.Concat("Failed: (", sub.Error.Code,") ", sub.Error.Message));
continue;
}
_subs[symbol] = sub.Data;
Console.WriteLine("Connected");
}
}
private static void Sub_Error(string symbol, Exception e)
{
Console.WriteLine(string.Concat("Sub Error w/ ", symbol,": ", e.Message));
}
private static void Sub_Closed(string symbol, bool autoReconnect = true)
{
Console.WriteLine(string.Concat("Sub Closed: ", symbol));
if(autoReconnect)
{
Console.WriteLine(string.Concat("Reconnecting to ", symbol));
// dont auto reconnect this sub since we can't impose a delay without dealing with threads
Subscribe(false, symbol);
// but if you wanted to make Sub_Closed async, you could also do:
// Console.WriteLine(string.Concat("Reconnecting to ", symbol, " in 5s"));
// await System.Threading.Tasks.Task.Delay(5000);
}
}
from binance.net.
I've implemented an auto reconnect try. When the connection gets closed it will try to reconnect. This will handle the auto disconnect Binance does every 24 hours automatically. For reconnecting after loss of internet a solution as @RonaldSwaine provided should do. I'll probably implement some method to be able to reconnect a subscription easier later on.
from binance.net.
I've implemented auto reconnecting in the latest version (v3.0.10)
from binance.net.
Related Issues (20)
- Error <WebCallResult<BinanceFuturesPlacedOrder> not found (Binance.Net 9.40) HOT 2
- Update request to SideEffectType HOT 1
- Enum missing values: EXPIRED_IN_MATCH / TRADE_PREVENTION HOT 1
- GetLendingAccountAsync Deprecated HOT 3
- Binance RestClient: Error "You are not authorized to execute this request." when calling ConvertQuoteRequestAsync
- Is there any option for binance lead trader api connection and place order?
- SubscribeToOrderBookUpdatesAsync is not working for spot HOT 2
- BinanceSocketClient Orderbook explained
- BinanceSocketClient.UsdFuturesApi.SubscribeToTradeUpdatesAsync() Stream has sporadic price Updates which are NOT real HOT 8
- "SubscribeToUserDataUpdatesAsync" stop working after 9.5.0 HOT 2
- UsdFuturesApi - onOrderUpdate HOT 5
- Binance - Spot Trading Via WebSockets - Order Request Rate Limits HOT 1
- how set socket5 proxy on BinanceRestClient or BinanceSocketClient at first dircetly? HOT 2
- Missing BinanceSocketClient.UsdFuturesApi.Account.GetAccountInfoAsync ? HOT 1
- https://jkorf.github.io/Binance.Net/ It's broken HOT 4
- Performance issues HOT 3
- SimpleEarn => Signature for this request is not valid. HOT 2
- Missing AUTO_BORROW_REPAY HOT 1
- BinanceSocketClient - Can't connect to the server HOT 1
- GetMarginLoansAsync not adding a parameter to the parameter list HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binance.net.