Merge branch 'master' into origin-8442-cwl-crunch2
[arvados.git] / services / api / app / middlewares / rack_socket.rb
index 795df4a7fc0e1b1b77c94d3d29d92bff77b99fd7..8f82e585df07f431650270997325be9d6c7cf448 100644 (file)
@@ -69,7 +69,11 @@ class RackSocket
   def call env
     request = Rack::Request.new(env)
     if request.path_info == @endpoint and Faye::WebSocket.websocket?(env)
-      ws = Faye::WebSocket.new(env)
+      if @handler.overloaded?
+        return [503, {"Content-Type" => "text/plain"}, ["Too many connections, try again later."]]
+      end
+
+      ws = Faye::WebSocket.new(env, nil, :ping => 30)
 
       # Notify handler about new connection
       @handler.on_connect ws