Now you can rate limit websocket clients with a token based system to pump the brakes on clients that are asking too much of your relay
Enhancements
  • Add token based websocket rate limiter to websocket handler
    • Closes websocket connection and sends client "OK" rate limit message
      • Limits by client IP address
      • Sends gauge metric with client tag to StatsD server to keep track of rate limited clients
    • After some time passes, token bucket is refilled and client can make requests again provided they stay under their rate limit
  • Reply to client with "NOTICE" message when subscription closes
    • Also sends "OK" true message to client when event successfully added
  • Many organizational improvements in websocket handler
    • New ExtractedResponse and WebsocketMessages help organize and make for more readable code
      • Parse and format messages outside of the handler functions
Bug Fixes
  • Fixed duplicate EOSE message returned to client from websocket subscription handler
  • Fixed redis cached result parsing bug that was returning a single ] as content for a REQ message when redis cache returned b"[]"
    • Try/except block for parsing, does not send redis results less than 2 charecters back to websocket handler, instead sends EOSE