title: Troubleshooting the websocket limit in Azure, active connections
body: <p>I'm in the process of troubleshooting an App Service that is using websockets.
  It's running on service plan Basic which allows for 350 websockets.
  This is the only app on that plan that uses websockets.</p>
  
  <p>The problem is that after abou 20 hours I get 503 responses saying I reached my websocket limit.</p>
  
  <p>The setup right now has 3 clients connecting to the service.</p>
  
  <p>In the process of investigating websocket leakage in my app I would like to track the number of websockets in use.</p>
  
  <p>Is there anywhere, from my app or in Azure portal, where I can see the number of active websocket connections?</p>
  
  <p><strong>Follow up:</strong></p>
  
  <p>I've logged the websocket connections as <a href="https://stackoverflow.com/a/44896044/33236">Amor suggested</a>.
  The HTTP part of my app is still working, I can get dynamic results from the app which now reports what websocket connections are active and how many has been created since start.</p>
  
  <p>After restarting the app service and configured one client to reconnect indefinetely.</p>
  
  <p>It worked fine until the "total websocket connections" reached 350. At this time I shut down the client.</p>
  
  <p>The limit should be 350 concurrent connections but it looks like it is 350 in total since start.
  Most (at least 340) of these connections were initiated by a single client which disposed each connection before starting a new one, it has been shutdown once the limit was reached.</p>
  
  <p>I've been suggested to upgrade from Basic to Standard since standard doesn't have the artificial limitation. The only reason I can see this work would be if there is a bug in the websocket limitation for the Basic plan.</p>
  
  <p><strong>Update 2</strong></p>
  
  <p>In parallel I've been in contact with Microsoft Developer Support and they noticed what <em>appears</em> to be that the sockets are stuck in IIS whereas not in Kestrel. The cause of this is still being investigated.</p>
  
  <p>Support could show me graphs of the connection usage over time which clearly showed how the limit was reached.</p>
  
  <p>I'll keep this question updated in case there was some error in my code.</p>