I've been running my ticker-bot to gather order book from Stellar Network. However, it did not work since probably few hours ago.

The bot is tiny program written in Python which just pinging orderbook using curl package.

import pycurl
from io import BytesIO

buffer = BytesIO()
c = pycurl.Curl()
c.setopt(c.URL, 'https://horizon.stellar.org/order_book?selling_asset_type=credit_alphanum4&selling_asset_code=MOBI&selling_asset_issuer=GA6HCMBLTZS5VYYBCATRBRZ3BZJMAFUDKYYF6AH6MVCMGWMRDNSWJPIH&buying_asset_type=native&buying_asset_code=XLM&buying_asset_issuer=native&limit=10')
c.setopt(c.WRITEDATA, buffer)


body = buffer.getvalue() 

The result is, blocked by Cloudflare (masking IP by hands):

b'<!DOCTYPE html>\n<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->\n<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->\n<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->\n<head>\n<title>Access denied | horizon.stellar.org used Cloudflare to restrict access</title>\n<meta charset="UTF-8" />\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />\n<meta name="robots" content="noindex, nofollow" />\n<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />\n<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/cf.errors.css" type="text/css" media="screen,projection" />\n<!--[if lt IE 9]><link rel="stylesheet" id=\'cf_styles-ie-css\' href="/cdn-cgi/styles/cf.errors.ie.css" type="text/css" media="screen,projection" /><![endif]-->\n<style type="text/css">body{margin:0;padding:0}</style>\n\n\n<!--[if gte IE 10]><!--><script type="text/javascript" src="/cdn-cgi/scripts/zepto.min.js"></script><!--<![endif]-->\n<!--[if gte IE 10]><!--><script type="text/javascript" src="/cdn-cgi/scripts/cf.common.js"></script><!--<![endif]-->\n\n\n\n</head>\n<body>\n  <div id="cf-wrapper">\n    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>\n    <div id="cf-error-details" class="cf-error-details-wrapper">\n      <div class="cf-wrapper cf-header cf-error-overview">\n        <h1>\n          <span class="cf-error-type" data-translate="error">Error</span>\n          <span class="cf-error-code">1010</span>\n          <small class="heading-ray-id">Ray ID: 47d875148fa3a56c &bull; 2018-11-22 03:54:53 UTC</small>\n        </h1>\n        <h2 class="cf-subheadline">Access denied</h2>\n      </div><!-- /.header -->\n\n      <section></section><!-- spacer -->\n\n      <div class="cf-section cf-wrapper">\n        <div class="cf-columns two">\n          <div class="cf-column">\n            <h2 data-translate="what_happened">What happened?</h2>\n            <p>The owner of this website (horizon.stellar.org) has banned your access based on your browser\'s signature (47d875148fa3a56c-ua47).</p>\n          </div>\n\n          \n        </div>\n      </div><!-- /.section -->\n\n      <div class="cf-error-footer cf-wrapper">\n  <p>\n    <span class="cf-footer-item">Cloudflare Ray ID: <strong>47d875148fa3a56c</strong></span>\n    <span class="cf-footer-separator">&bull;</span>\n    <span class="cf-footer-item"><span>Your IP</span>: ***.***.***.***</span>\n    <span class="cf-footer-separator">&bull;</span>\n    <span class="cf-footer-item"><span>Performance &amp; security by</span> <a href="https://www.cloudflare.com/5xx-error-landing?utm_source=error_footer" id="brand_link" target="_blank">Cloudflare</a></span>\n    \n  </p>\n</div><!-- /.error-footer -->\n\n\n    </div><!-- /#cf-error-details -->\n  </div><!-- /#cf-wrapper -->\n\n  <script type="text/javascript">\n  window._cf_translation = {};\n  \n  \n</script>\n\n</body>\n</html>\n'

I heard some kinds of DDOS attack was happened few hours ago. Surely, I'm not a DDOS attacker. I've been pinging above query every seconds and it worked for months. Even when I pinging orderbook by using curl in bash shell same machine, it retrieves orderbook correctly.

# curl "https://horizon.stellar.org/order_book?selling_asset_type=credit_alphanum4&selling_asset_code=MOBI&selling_asset_issuer=GA6HCMBLTZS5VYYBCATRBRZ3BZJMAFUDKYYF6AH6MVCMGWMRDNSWJPIH&buying_asset_type=native&buying_asset_code=XLM&buying_asset_issuer=native&limit=10"

  "bids": [
      "price_r": {
        "n": 10000000,
        "d": 107526881
      "price": "0.0930000",
      "amount": "181.3500000"
      "price_r": {
        "n": 927709,
        "d": 10000000
      "price": "0.0927709",
      "amount": "4.6195392"

Anyone could help this? I will really appreciate for this.


I found the answer by myself. Blocked reason was:

The owner of this website (horizon.stellar.org) has banned your access based on your browser\'s signature (47d941e83d91129d-ua47).

so I added USERAGENT option:

c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows NT 6.1; Win64; x64;en; rv:5.0) Gecko/20110619 Firefox/5.0")

Now, it works well. Thank you.

| improve this answer | |
  • 1
    Have you tried streaming the order book updates instead? – Johan Stén Nov 22 '18 at 6:34
  • @JohanStén No, I haven't. I have no idea about it. I am using py-stellar-base package to manage orders. I found the function retrieving orderbooks in that package, but I have failed to use it. If you know the way listen to streaming the orderbook, please let me refer that. – kangbu Nov 23 '18 at 7:29
  • I haven't used it in years myself, so I can't guide you. I just know that it has a streaming mode where you get sent any new updates to the order book when they arrive, so you don't have to poll all the time. – Johan Stén Nov 23 '18 at 8:53
  • @JohanStén Thank for your tip. I will try to find it out. – kangbu Nov 23 '18 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.