2011-12-30 4 views
0

에 http put 요청을 보내면 werkzeug를 사용하여 요청을 수신하고 처리합니다. 기능 중 하나에서 요청 (A에서 말)을 듣고 다른 서버 (B)로 http put 요청을 보내야합니다. 그런 다음 B에서 응답을받은 후 A 응답으로 응답해야합니다.내 웹 응용 프로그램에서 werkzeug

저는 werkzeug에 익숙하지 않아서 요청을 보낼 수있는 능력이 있는지 확신 할 수 없으므로 요청을 보내기 위해 httplib를 사용했습니다.

하지만 오류가 발생합니다.

는 움직이는 부분이 많이있다, 나는 다음과 같은 궁금 : 1. 것은 WERKZEUG 어떤 도움을 주셔서 감사합니다 오류

의 원인이 무엇인지 요청 2를 보낼 수있는 능력을 가지고있다.

코드 :

def complete(self, request): 
    if request.method == 'GET': 
     location_id = self.extract_param_value(request,'location_id'); 
     status_code = self.extract_param_value(request,'status_code'); 

     req_url = something; 
     jsonData = { 'data' : {'status' : status_code, 'id': location_id}}; 
     jsonDataDump = json.dumps(jsonData); 
     #send request to B 
     connection = httplib.HTTPConnection(HOST, timeout=5); 
     body_content = jsonDataDump; 
     headers = {"Content-type": "application/json", "Accept": "text/plain"}; 
     connection.request('PUT', req_url, body_content, headers); #error occurs here 
     result = connection.getresponse(); 
     connection.close(); 
     #return response to A 
     response = Response(status=200); 

     return response; 

가 오류 :

 1**.1**.1**.** - - [30/Dec/2011 03:06:57] "GET //complete?location_id=615201308&status_code=LIVE&message=fine HTTP/1.1" 500 - 
     Traceback (most recent call last): 
     File "/home/ec2-user/y_ws.py", line 381, in __call__ 
     return self.wsgi_app(environ, start_response) 
     File "/usr/lib/python2.6/site-packages/Werkzeug-0.8.1-py2.6.egg/werkzeug/wsgi.py", line 411, in __call__ 
      return self.app(environ, start_response) 
      File "/home/ec2-user/y_ws.py", line 377, in wsgi_app 
      response = self.dispatch_request(request); 
      File "/home/ec2-user/y_ws.py", line 98, in dispatch_request 
      return getattr(self, endpoint)(request, **values) 
      File "/home/ec2-user/y_ws.py", line 184, in complete 
      connection.request('PUT', y_req_url, body_content, headers); 
      File "/usr/lib64/python2.6/httplib.py", line 914, in request 
      self._send_request(method, url, body, headers) 
      File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request 
      self.endheaders() 
      File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders 
      self._send_output() 
      File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output 
      self.send(msg) 
      File "/usr/lib64/python2.6/httplib.py", line 739, in send 
      self.connect() 
      File "/usr/lib64/python2.6/httplib.py", line 720, in connect 
      self.timeout) 
      File "/usr/lib64/python2.6/socket.py", line 567, in create_connection 
      raise error, msg 
     error: [Errno 111] Connection refused 

답변

1
  1. WERKZEUG는 HTTP 요청을 만들기위한 라이브러리가 아닌, (당신의 예에서와 같이) HTTPLIB를 사용 컬은 if와
  2. 확인 요청은 호스트 시스템에서 성공하여 네트워크 문제를 배제합니다. 오류는 일반적인 네트워크 오류입니다.