Skip to content
Browse files

modify app according to the change of mongodb proxy

  Old mongodb proxy will close TCP connection when quota exceeds, so
  app will get 'Connection Reset' exception. New mongodb proxy will
  half close TCP connection when quota exceeds, so, app will get
  'Broken pipe' or 'ConnectionFailure' exception.

  Here, we make the app happy with both old proxy and new proxy.

Change-Id: If22829a95699e716e44dc08f7268191d2c4d1678
  • Loading branch information...
1 parent c1ccd1c commit 00b1fd1bb937c035e7e299183a7b84145b27b21f Chunjie committed Dec 10, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 sinatra/app_sinatra_service_quota/main.rb
View
11 sinatra/app_sinatra_service_quota/main.rb
@@ -123,8 +123,15 @@
rescue Exception => e
puts e.message
# proxy will drop the connection if 'Quota Exceed', the error message
- # contains keyword 'Connection reset by peer'
- return e.message
+ # contains keyword 'Broken pipe' or 'ConnectionFailure' or
+ # 'Connection reset by peer'
+ if e.message.include?("Broken pipe") or
+ e.message.include?("ConnectionFailure") or
+ e.message.include?("Connection reset by peer")
+ return "Connection Blocked"
+ else
+ return e.message
+ end
end
end

0 comments on commit 00b1fd1

Please sign in to comment.
Something went wrong with that request. Please try again.