.net - SignalR Hub client - bypass cloudflare with ClearanceDelegate -
i trying bypass cloudflare check implemented on bittrex.com signalr hub endpoint.
i using utility create clearencedelegate: https://github.com/elcattivo/cloudflareutilities
this working regular httprequestmessages, trying hub connect.
i have attached _cfduid , cf_clearance cookies, , added user-agent header identical initial request, though still cant connect... same 503 if had done nothing.
is there possibly way force hubconnection obj use initial httpclient or handler?
var handler = new clearancehandler(); var client = new httpclient(handler); var hubconnection = new hubconnection("https://www.bittrex.com/"); try { httprequestmessage msg = new httprequestmessage() { requesturi = new uri("https://www.bittrex.com/"), method = httpmethod.get }; httpresponsemessage response = await client.sendasync(msg); if (response.issuccessstatuscode) { console.writeline("success"); } ienumerable<string> heads; if (msg.headers.trygetvalues("user-agent", out heads)) { foreach (string s in heads) { console.writeline(s); //outputs: "client/1.0" //add user-agent header hubconnection hubconnection.headers.add("user-agent", s); } } hubconnection.cookiecontainer = new cookiecontainer(); ienumerable<string> cookies; //set "_cfduid" , "cf_clearance" cookies recieved on hubconnection if (response.headers.trygetvalues("set-cookie", out cookies)) { foreach (var c in cookies) { uri target = new uri("https://www.bittrex.com/"); hubconnection.cookiecontainer.setcookies(target, c); } } } catch (aggregateexception ex) when (ex.innerexception cloudflareclearanceexception) { console.writeline(ex.innerexception.message); } console.writeline("connecting"); //try connect hub attached cookies , user-agent header: await hubconnection.start(); btrexhubproxy.on<marketdataupdate>("updateexchangestate", update => btrexrobot.updateenqueue(update)); //btrexhubproxy.on<summariesupdate>("updatesummarystate", update => console.writeline("full summary: ")); btrexhubproxy = hubconnection.createhubproxy("corehub");
Comments
Post a Comment