I've been using the Elasticsearch Python API to do some basic operation on a cluster (like creating an index or listing them). Everything worked fine but I decided to activate SSL authentification on the cluster and my scripts aren't working anymore.
I have the following errors :
Certificate did not match expected hostname: X.X.X.X. Certificate: {'subject': ((('commonName', 'X.X.X.X'),),), 'subjectAltName': [('DNS', 'X.X.X.X')]} GET https://X.X.X.X:9201/ [status:N/A request:0.009s] Traceback (most recent call last): File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked, File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn) File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
conn.connect() File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connection.py", line 386, in connect
_match_hostname(cert, self.assert_hostname or server_hostname) File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connection.py", line 396, in _match_hostname
match_hostname(cert, asserted_hostname) File "/home/esadm/env/lib/python3.7/ssl.py", line 338, in match_hostname
% (hostname, dnsnames[0])) ssl.SSLCertVerificationError: ("hostname 'X.X.X.X' doesn't match 'X.X.X.X'",)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/esadm/env/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 233, in perform_request
method, url, body, retries=Retry(False), headers=request_headers, **kw File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2] File "/home/esadm/env/lib/python3.7/site-packages/urllib3/util/retry.py", line 376, in increment
raise six.reraise(type(error), error, _stacktrace) File "/home/esadm/env/lib/python3.7/site-packages/urllib3/packages/six.py", line 734, in reraise
raise value.with_traceback(tb) File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
chunked=chunked, File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn) File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
conn.connect() File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connection.py", line 386, in connect
_match_hostname(cert, self.assert_hostname or server_hostname) File "/home/esadm/env/lib/python3.7/site-packages/urllib3/connection.py", line 396, in _match_hostname
match_hostname(cert, asserted_hostname) File "/home/esadm/env/lib/python3.7/ssl.py", line 338, in match_hostname
% (hostname, dnsnames[0])) urllib3.exceptions.SSLError: ("hostname 'X.X.X.X' doesn't match 'X.X.X.X'",)
The thing I don't understand is that this message doesn't make any sense :
"hostname 'X.X.X.X' doesn't match 'X.X.X.X'"
Because the two adresses matches, they are exactly the same !
I've followed the docs and my configuration of the instance Elasticsearch looks like this :
Elasticsearch([get_ip_address()],
http_auth=('elastic', 'pass'),
use_ssl=True,
verify_certs=True,
port=get_instance_port(),
ca_certs='ca.crt',
client_cert='pvln0047.crt',
client_key='pvln0047.key'
)
Thanks for your help
Problem solved, the issue was in the constructor :
Elasticsearch([get_ip_address()],
http_auth=('elastic', 'pass'),
use_ssl=True,
verify_certs=True,
port=get_instance_port(),
ca_certs='ca.crt',
client_cert='pvln0047.crt',
client_key='pvln0047.key'
)
Instead of mentioning the ip address I needed to mention the DNS name, I also changed the arguments by using context object just to follow the original docs.
context = create_default_context(cafile="ca.crt")
context.load_cert_chain(certfile="pvln0047.crt", keyfile="pvln0047.key")
context.verify_mode = CERT_REQUIRED
Elasticsearch(['dns_name'],
http_auth=('elastic', 'pass'),
scheme="https",
port=get_instance_port(),
ssl_context=context
)
This is how I generated the certificates :
bin/elasticsearch-certutil cert ca --pem --in /tmp/instance.yml --out /home/user/certs.zip
And this is my instance.yml file :
instances:
- name: 'dns_name'
dns: [ 'dns_name' ]
Hope, it will help someone !
Related
SOLVED
I will start off with I've never dealt with HTTP requests, and I've tried a few examples that I saw here on the website, but none of them worked for my case.
I want to "activate" scripts that are on a hardware device that I am trying to control. The device has its own HTTP server and by using various URLs I can change its variables, such url looks like this:
http://ipofdevice/ScriptName?varName=varValue&varName2=varValue2&varNameN=varValueN
I am trying to figure out how can I "activate" such URLs with python and I've gotten as far as, that I have to use post requests (I think?) and here is what I've tried so far:
I have already checked a few other posts and tried sample codes from there, but none of them worked, one such post was this:
How to send POST request?
Here is are two sample codes that I have tried, but did not work:
from urllib.parse import urlencode
from urllib.request import Request, urlopen
url = "http://127.0.0.1/ScriptName"
post_fields = { 'testVar' : 'hello', 'secondVar' : 'fromPython' }
request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode()
And the json line threw an exception with a very long Traceback
Traceback (most recent call last):
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 289, in _read_status
status = int(status)
ValueError: invalid literal for int() with base 10: '400,'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 542, in _open
result = self._call_chain(self.handle_open, protocol, protocol +
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1348, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 1323, in do_open
r = h.getresponse()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 293, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: HTTP/1.0 400, Invalid Request
This is the code from my second attempt:
import requests
base_url = "http://127.0.0.1/ScriptName"
post_fields = { 'testVar' : 'hello', 'secondVar' : 'fromPython' }
response = requests.post(final_url, data=post_fields)
With an even much longer traceback, which I will not post simply because it adds too much clutter and I dont think its needed, since obviously I am doing something fundamentally wrong.
I dont need anything fancy, just to be able to run a link like the one in the beginning of the thread, I am not even sure if POST request is what I need.
In javascript I was able to do it like this (but javascript lacks other things that I need):
var wnd = window.open("http://127.0.0.1/ScriptName?var=val");
wnd.close();
e.preventDefault();
EDIT: Adding the traceback for the second python attempt:
Traceback (most recent call last):
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 293, in _read_status
raise BadStatusLine(line)
http.client.BadStatusLine: HTTP/1.0 400, Invalid Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 400, in increment
raise six.reraise(type(error), error, _stacktrace)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
raise value.with_traceback(tb)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
httplib_response = conn.getresponse()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse
response.begin()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 303, in begin
version, status, reason = self._read_status()
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 293, in _read_status
raise BadStatusLine(line)
urllib3.exceptions.ProtocolError: ('Connection aborted.', BadStatusLine('HTTP/1.0 400, Invalid Request\r\n'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 119, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Darkbound\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('HTTP/1.0 400, Invalid Request\r\n'))
EDIT 2: Solved, turns out that I actually needed a GET request as #MrBean Bremen suggested , all I had to do was:
import requests
requests.get(myurl)
Try this
import requests
tesVar = hello
secondVar = fromPython
baseurl = "http://127.0.0.1/ScriptName?{'tesVar'}&{'secondVar'}"
response = requests.get(baseurl)
print(response)
UPDATE: I managed to do a request with urllib2, but I'm still wondering what is happening here.
I would like to do a HTTPS request with Python.
This works fine with the requests module, but I don't want to use external dependencies, so I'd like to use the standard library.
httplib
When I follow this example I don't get a response. I get a timeout instead. I'm out of ideas as to what would cause this.
Code:
import requests
print requests.get('https://python.org')
from httplib import HTTPSConnection
conn = HTTPSConnection('www.python.org')
conn.request('GET', '/index.html')
print conn.getresponse()
Output:
<Response [200]>
Traceback (most recent call last):
File "test.py", line 6, in <module>
conn.request('GET', '/index.html')
File "C:\Python27\lib\httplib.py", line 1069, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 1109, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 1065, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 892, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 854, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1282, in connect
HTTPConnection.connect(self)
File "C:\Python27\lib\httplib.py", line 831, in connect
self.timeout, self.source_address)
File "C:\Python27\lib\socket.py", line 575, in create_connection
raise err
socket.error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
urllib
This fails for a different (but possibly related) reason. Code:
import urllib
print urllib.urlopen("https://python.org")
Output:
Traceback (most recent call last):
File "test.py", line 10, in <module>
print urllib.urlopen("https://python.org")
File "C:\Python27\lib\urllib.py", line 87, in urlopen
return opener.open(url)
File "C:\Python27\lib\urllib.py", line 215, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 445, in open_https
h.endheaders(data)
File "C:\Python27\lib\httplib.py", line 1065, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 892, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 854, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1290, in connect
server_hostname=server_hostname)
File "C:\Python27\lib\ssl.py", line 369, in wrap_socket
_context=self)
File "C:\Python27\lib\ssl.py", line 599, in __init__
self.do_handshake()
File "C:\Python27\lib\ssl.py", line 828, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:727)
What is requests doing that makes it succeed where both of these libraries fail?
requests.get without timeout parameter mean no timeout at all.
httplib.HTTPSConnection accept parameter timeout in Python 2.6 and newer according to httplib docs. If your problem was caused by timeout, setting high enough timeout should help. Please try replacing:
conn = HTTPSConnection('www.python.org')
with:
conn = HTTPSConnection('www.python.org', timeout=300)
which will give 300 seconds (5 minutes) for processing.
The duty of my function is to calculate the distance from my business to any address (at the end (print fucntion) I put an example of an address)). I don´t know why it is not working, it says something about traceback error.
The first part of my function, converts from address to coordinates.
The second part calculate the distance.
THIS IS THE CODE
import math
from geopy.geocoders import Nominatim
def Distancia(direccion_domicilio):
geolocator = Nominatim(user_agent="specify_your_app_name_here")
location = geolocator.geocode(direccion_domicilio)
latylon=(location.latitude, location.longitude)
rad=math.pi/180
dif_lat = 20.6072848-(latylon[0])
dif_long = -103.4160099-(latylon[1])
radio=6372.795477598
a=(math.sin(rad*dif_lat/2))**2 + math.cos(rad*location.latitud)*math.cos(rad*20.6072848)*(math.sin(rad*dif_long/2)**2)
distancia=2*radio*math.asin(math.sqrt(a))
return distancia
print(Distancia("Avenida Guadalupe, Real Guadalupe, Jardines de Chapalita, Zapopan, Jalisco, 45030, México"))
THIS IS THE ERROR MESSAGE
Traceback (most recent call last):
File "C:\Python37\lib\urllib\request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "C:\Python37\lib\http\client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "C:\Python37\lib\http\client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "C:\Python37\lib\http\client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "C:\Python37\lib\http\client.py", line 1016, in _send_output
self.send(msg)
File "C:\Python37\lib\http\client.py", line 956, in send
self.connect()
File "C:\Python37\lib\http\client.py", line 1392, in connect
server_hostname=server_hostname)
File "C:\Python37\lib\ssl.py", line 412, in wrap_socket
session=session
File "C:\Python37\lib\ssl.py", line 850, in _create
self.do_handshake()
File "C:\Python37\lib\ssl.py", line 1108, in do_handshake
self._sslobj.do_handshake()
socket.timeout: _ssl.c:1029: The handshake operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python37\lib\site-packages\geopy\geocoders\base.py", line 344, in _call_geocoder
page = requester(req, timeout=timeout, **kwargs)
File "C:\Python37\lib\urllib\request.py", line 525, in open
response = self._open(req, data)
File "C:\Python37\lib\urllib\request.py", line 543, in _open
'_open', req)
File "C:\Python37\lib\urllib\request.py", line 503, in _call_chain
result = func(*args)
File "C:\Python37\lib\urllib\request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python37\lib\urllib\request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error _ssl.c:1029: The handshake operation timed out>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Dell\Documents\Python programas\Ejercicios extras\PROYECTOdistancia.py", line 18, in <module>
print(Distancia("Avenida Guadalupe, Real Guadalupe, Jardines de Chapalita, Zapopan, Jalisco, 45030, México"))
File "C:\Users\Dell\Documents\Python programas\Ejercicios extras\PROYECTOdistancia.py", line 6, in Distancia
location = geolocator.geocode(direccion_domicilio)
File "C:\Python37\lib\site-packages\geopy\geocoders\osm.py", line 307, in geocode
self._call_geocoder(url, timeout=timeout), exactly_one
File "C:\Python37\lib\site-packages\geopy\geocoders\base.py", line 367, in _call_geocoder
raise GeocoderTimedOut('Service timed out')
geopy.exc.GeocoderTimedOut: Service timed out
You did not perform a whole installation process. Traceback tells you what is happening. It says that there is a problem with SSL certificate. geopy library retrieves data from web (Nomitatiom in your case).
Take a look at this documentation: https://geopy.readthedocs.io/en/stable/#geopy.geocoders.options and option called default_ssl_context.
You should use this code at the beginning of yours code (from the above documentation):
to use SSL use:
import ssl
import certifi
import geopy.geocoders
ctx = ssl.create_default_context(cafile=certifi.where())
geopy.geocoders.options.default_ssl_context = ctx
to disable SSL (not recommended, may not even work for some geo providers):
import ssl
import geopy.geocoders
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
geopy.geocoders.options.default_ssl_context = ctx
I am aware there is a patch for using the REST API with a proxy and it works for me. But the Streaming API uses a HTTPConnection which cannot be emulated by urllib and urllib2 (as far as I know). Is there any fix for this?
I tried using proxy with port, but it did not work.
In the streaming.py file, line 153.
if self.scheme == "http":
conn = httplib.HTTPConnection(self.api.proxy_host,self.api.proxy_port, timeout=self.timeout)
else:
conn = httplib.HTTPSConnection(self.api.proxy_host,self.api.proxy_port,timeout=self.timeout)
self.auth.apply_auth(url, 'POST', self.headers, self.parameters)
print conn.host
conn.connect()
conn.request('POST', self.scheme+'://'+self.host+self.url, self.body, headers=self.headers)
resp = conn.getresponse()
And, "self.scheme+'://'+self.host+ self.url" corresponds to - https://stream.twitter.com/1.1/statuses/filter.json?delimited=length
I get this error in return -
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 2538, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-3-4798d330f7cd>", line 1, in <module>
execfile('main.py')
File "main.py", line 130, in <module>
streamer.filter(track = ['AAP'])
File "/usr/local/lib/python2.7/dist-packages/tweepy/streaming.py", line 305, in filter
self._start(async)
File "/usr/local/lib/python2.7/dist-packages/tweepy/streaming.py", line 242, in _start
self._run()
File "/usr/local/lib/python2.7/dist-packages/tweepy/streaming.py", line 159, in _run
conn.connect()
File "/usr/lib/python2.7/httplib.py", line 1161, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "/usr/lib/python2.7/ssl.py", line 381, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 143, in __init__
self.do_handshake()
File "/usr/lib/python2.7/ssl.py", line 305, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 1] _ssl.c:504: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Tweepy currently does not support using a proxy. However, support for proxies should be coming in the next few days. I'll update this answer with more information.
Finally found a github patch that enabled streaming api via proxy. It works just fine!
https://github.com/shogo82148/tweepy/blob/64c6266018920e0e36c6d8d1600adb6caa0840de/tweepy/streaming.py
This is a code for posting on a blog. It is my first try. I dont know what is the error in it. I am using proxy server and the error I'm getting is connection to server failed.
Can anyone help me out pleaseeeeeeeeee :/
import wordpresslib
# dummy data to be on safe side
data = "Post content, just ensuring data is not empty"
url='http://agneesa.wordpress.com/wordpress/xmlrpc.php'
# insert correct username and password
wp=wordpresslib.WordPressClient(url,'agnsa','pan#13579')
wp.selectBlog(0)
post=wordpresslib.WordPressPost()
post.title='try'
post.description=data
idPost=wp.newPost(post,True)
here is the traceback
here is the traceback file
Traceback (most recent call last):
File "C:\Python27\Lib\example.py", line 34, in <module>
post.categories = (wp.getCategoryIdFromName('Python'),)
File "C:\Python27\Lib\wordpresslib.py", line 332, in getCategoryIdFromName
for c in self.getCategoryList():
File "C:\Python27\Lib\wordpresslib.py", line 321, in getCategoryList
self.user, self.password)
File "C:\Python27\Lib\xmlrpclib.py", line 1224, in __call__
return self.__send(self.__name, args)
File "C:\Python27\Lib\xmlrpclib.py", line 1578, in __request
verbose=self.__verbose
File "C:\Python27\Lib\xmlrpclib.py", line 1264, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Python27\Lib\xmlrpclib.py", line 1292, in single_request
self.send_content(h, request_body)
File "C:\Python27\Lib\xmlrpclib.py", line 1439, in send_content
connection.endheaders(request_body)
File "C:\Python27\Lib\httplib.py", line 954, in endheaders
self._send_output(message_body)
File "C:\Python27\Lib\httplib.py", line 814, in _send_output
self.send(msg)
File "C:\Python27\Lib\httplib.py", line 776, in send
self.connect()
File "C:\Python27\Lib\httplib.py", line 757, in connect
self.timeout, self.source_address)
File "socket.py", line 571, in create_connection
raise err
error: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
From the looks of your site, the url you posted returns a 404 (not actually there). However, this does seem ready to receive POST requests: http://agneesa.wordpress.com/xmlrpc.php
I suggest you try checking that URL for accuracy.
This is what I get when I try your code with your original URL:
xmlrpclib.ProtocolError: <ProtocolError for \
agneesa.wordpress.com/wordpress/xmlrpc.php: 404 Not Found>
This is what I get when I try it with the modified URL:
wordpresslib.WordPressException: \
<WordPressException 403: 'Bad login/pass combination.'>
... obviously because thats not your real account info. In a nutshell, its possible your proxy could also be contributing to problems if its not set up to properly forward the request, but without us knowing specifics about your proxy config, there is no way to know for sure.