502 Bad Gateway : Registered ednpoint failed to handle the request

1,525 views
Skip to first unread message

lasky

unread,
Nov 26, 2013, 5:23:15 AM11/26/13
to vcap...@cloudfoundry.org
Hi,

I have added a service broker to cloudfoundry,but a exception raised when i was trying to create a service with the broker. It tell that:

CFoudry::BadResponse: 502: 502 Bad Gateway: Registered ednpoint failed to handle the request.

In my opinion, it shoud be a timeout exception. When CFoundry send a PUT requet to cc,it will wait a response in a default time(60s?). But it will take a few minutes to the creation which may lead to the exception. So does cc(sends a PUT request to service broker).  

Then i try to increase the waitint time by modifying the read_timeout: 

~/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/cfoundry-4.6.1/lib/cfoundry/rest_client.rb #request_uri
      http = HTTPFactory.create(uri, proxy_options_for(uri))

      # TODO remove this when staging returns streaming responses
      http.read_timeout = 10*60
      http.open_timeout = 60

      before = Time.now
      http.start do
        response = http.request(request)
        time = Time.now - before

and  /var/vcap/packages/cloud_controller_ng/cloud_controller_ng/app/models/services/service_broker/v2/http_client.rb #
      begin
          req_class = method.to_s.capitalize
          req = Net::HTTP.const_get(req_class).new(uri.request_uri)
          req.basic_auth(auth_username, auth_password)
          req.body = body
          req.content_type = 'application/json'
          req[VCAP::Request::HEADER_NAME] = VCAP::Request.current_id
          req['Accept'] = 'application/json'

          logger.debug "Sending #{req_class} to #{uri}, BODY: #{req.body}, HEADERS: #{req.to_hash.inspect}"

          response = Net::HTTP.start(uri.hostname, uri.port) do |http|
            # TODO: make this configurable?
            http.open_timeout = 60
            http.read_timeout = 10*60
            #http.continue_timeout = 90

            http.request(req)
          end
  

But it seems like that it only makes sense to cc, and the CFoundry raises the exception again. The difference is that the creation of service is finished, i can see the service by cf services.

So,what's the problem and what should i do?  

Any reply is appreciated. Thanks!

wanjq...@gmail.com

unread,
Nov 29, 2013, 9:41:32 PM11/29/13
to vcap...@cloudfoundry.org
Hi,friends

I have also encountered the same problem . Who can give me some tips so that I can solve this problem?
Here is the error:



CFoundry::BadResponse: 502: 502 Bad Gateway: Registered endpoint failed to handle the request.

cat
~/.cf/crash # for more details

cloud@ict
:~$ cat /home/cloud/.cf/crash

Time of crash:
 
2013-11-30 10:19:06 +0800

CFoundry::BadResponse: 502: 502 Bad Gateway: Registered endpoint failed to handle the request.

<<<
REQUEST
: POST http://api.vcap.me/v2/service_instances
REQUEST_HEADERS
:
 
Accept : application/json
 
Authorization : [PRIVATE DATA HIDDEN]
 
Content-Length : 138
 
Content-Type : application/json
REQUEST_BODY
: {"name":"nc_service-b783a","service_plan_guid":"2f2d1593-b45a-40d6-83cb-97cf80f3f0cf","space_guid":"000891ea-cce2-4807-b517-8114cd335981"}
RESPONSE
: [502]
RESPONSE_HEADERS
:
  content
-type : text/plain; charset=utf-8
  date
: Sat, 30 Nov 2013 02:19:12 GMT
  transfer
-encoding : chunked
  x
-cf-routererror : endpoint_failure
RESPONSE_BODY
:
502 Bad Gateway: Registered endpoint failed to handle the request.
>>>

cfoundry
-4.2.0.rc/lib/cfoundry/baseclient.rb:180:in `handle_error_response'
cfoundry-4.2.0.rc/lib/cfoundry/baseclient.rb:148:in `
handle_response'
cfoundry-4.2.0.rc/lib/cfoundry/baseclient.rb:89:in `request'

cfoundry
-4.2.0.rc/lib/cfoundry/baseclient.rb:74:in `post'
cfoundry-4.2.0.rc/lib/cfoundry/v2/model.rb:123:in `
create!'
cf-5.0.0.rc3/lib/cf/cli/service/create.rb:94:in `block in create_service'

interact
-0.5.2/lib/interact/progress.rb:98:in `with_progress'
cf-5.0.0.rc3/lib/cf/cli/service/create.rb:93:in `
create_service'
mothership-0.5.1/lib/mothership/base.rb:66:in `run'

mothership
-0.5.1/lib/mothership/command.rb:72:in `block in invoke'
mothership-0.5.1/lib/mothership/command.rb:86:in `
instance_exec'
mothership-0.5.1/lib/mothership/command.rb:86:in `invoke'

mothership
-0.5.1/lib/mothership/base.rb:55:in `execute'
cf-5.0.0.rc3/lib/cf/cli.rb:187:in `
block (2 levels) in execute'
cf-5.0.0.rc3/lib/cf/cli.rb:198:in `save_token_if_it_changes'

cf
-5.0.0.rc3/lib/cf/cli.rb:186:in `block in execute'
cf-5.0.0.rc3/lib/cf/cli.rb:122:in `
wrap_errors'
cf-5.0.0.rc3/lib/cf/cli.rb:182:in `execute'

mothership
-0.5.1/lib/mothership.rb:45:in `start'
cf-5.0.0.rc3/bin/cf:16:in `
<top (required)>'





在 2013年11月26日星期二UTC+8下午6时23分15秒,lasky写道:

James Bayer

unread,
Dec 1, 2013, 12:35:08 AM12/1/13
to vcap...@cloudfoundry.org
one of the items on the services api roadmap is to incorporate asynchronous interactions that are not subject to a relatively short timeout like the ones you both are experiencing. hopefully someone on the services team has some suggestions for you in the meantime.


To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.



--
Thank you,

James Bayer

Shannon Coen

unread,
Dec 2, 2013, 1:32:23 PM12/2/13
to vcap...@cloudfoundry.org
In the near term we are working to provide a configurable timeout parameter for cloud controller in the deployment manifest. Currently this timeout is hardcoded. Although each long running request will hold a thread open in cc (cc will crash if it runs out of threads), and long running synchronous requests are a poor user experience, it will enable service developers to continue development. We recommend service developers investigate techniques for speeding up provisioning like multi-tenancy, pools of warm clusters, and pools of warm vms. 

As James mentioned, the long term plan is to add support for asynchronous service requests. This effort is currently in a phase of design and initial implementation. 
Reply all
Reply to author
Forward
0 new messages