로컬 서버가 6868 번 포트에서 실행됩니다. 기술적으로 node.js 기반의 마이크로 사이트 인 express가 있습니다. 실제로는 일부 데이터를 읽고 콘솔에 쓰는 단일 '/ 푸시'constroller를 가지고 있습니다 (특정 질문이 아닌 특정 operatons). python httplib timeout to localhost
컬h100:~ eugenemirotin$ curl -i http://127.0.0.1:6868/push -d password=pwd
HTTP/1.1 200 OK
X-Powered-By: Express
Connection: keep-alive
Transfer-Encoding: chunked
를 사용하여 가정으로 콘솔에 wites를 Node.js를.
파이썬과 HTTPLIB를 사용하여 :h100:~ eugenemirotin$ python
Python 2.7.1 (r271:86832, Jan 6 2011, 00:55:07)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib, urllib
>>> params = {'password': 'pwd', 'type': 'msg', 'channel': 'chat', 'client_id': '', 'body': {'text': 'test test'}}
>>> params
{'body': {'text': 'test test'}, 'password': 'pwd', 'type': 'msg', 'client_id': '', 'channel': 'chat'}
>>> params = urllib.urlencode(params)
>>> params
'body=%7B%27text%27%3A+%27test+test%27%7D&password=pwd&type=msg&client_id=&channel=chat'
>>> conn = httplib.HTTPConnection('http://127.0.0.1:6868')
>>> conn.request("POST", "/push", params)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 941, in request
self._send_request(method, url, body, headers)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 975, in _send_request
self.endheaders(body)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 937, in endheaders
self._send_output(message_body)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 797, in _send_output
self.send(msg)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 759, in send
self.connect()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 740, in connect
self.timeout, self.source_address)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 571, in create_connection
raise err
socket.error: [Errno 60] Operation timed out
>>> quit()
매개 변수의 차이가 중요하지 않습니다 - 요청도 서버를 Node.js를 얻을하지 않습니다.
httplib 버그입니까? 아니면 잘못된 것입니까?
아, 감사합니다. 어리석은 httplib, 나는 – Guard