error: [Errno 10060] A connection attempt failed when using solrpy in python - python-2.7

when i am trying to run the following python code which uses solrpy,
enter code here
import solr
s = solr.SolrConnection('http://example.org:8080/solr')
s.add(id=1, title='Lucene in Action', author=['hello','lucky'])
s.commit()
response = s.query('title:lucene')
for hit in response.results:
print hit['title']
i am getting the following error:
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

You should point to a valid Solr (are you sure there is a Solr running at example.org?)

Related

Download Remote HDFS Files to My Local Mac

I need to download files from a HDFS file system to my Mac local machine:
import os
import pyhdfs
os.environ["http_proxy"] = "http://host:port"
os.environ["https_proxy"] = "http://host:port"
os.environ["no_proxy"] = "host_x,host_y,host_x,machine_name1,machine_name2,machine_name3"
client = pyhdfs.HdfsClient(hosts='host_x,host_y,host_z', user_name='username')
I got expected, desired output by running client.get_home_directory(), client.listdir('/some_remote_hadoop_directory/') and client.exists("/some_remote_hadoop_directory/file"). client.exists("/some_remote_hadoop_directory/file") returned True which was also a good sign. However, the command client.copy_to_local("/some_remote_hadoop_directory/file", "/my_local_mac_directory/file") gave me the following errors:
gaierror: [Errno 8] nodename nor servname provided, or not known
NewConnectionError: <urllib3.connection.HTTPConnection object at 0x1058b47c0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known
MaxRetryError: HTTPConnectionPool(host='host', port=port): Max retries exceeded with url: some_hadoop_url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1058b47c0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
ConnectionError: HTTPConnectionPool(host='host', port=port): Max retries exceeded with url: some_hadoop_url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1058b47c0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
I then checked online for solution and tried the one (i.e. modify /etc/hosts from https://stackoverflow.com/a/43549848/6693221) which had been shared by many across different platforms. However, this did not work for me. It seemed that my Mac could "talk" to the remote machine but failed to fetch data from it. I turned to configure my Mac by turning on System Preferences -> Sharing -> File Sharing and changed to everyone can read & write but still failed. I know this was meant to be easy but still had no clue what was really missing. I did this as a workaround for my previous question: How to read remote HDFS parquets from my local PySpark?

Solr in Flask web app - Failed to connect to server - Failed to establish a new connection: [Errno 111] Connection refused

I have indexed files successfully using Solr, and queried the core successfully by using pysolr. The code is working fine in the Pycharm Terminal. Now I am trying to convert the code to a web app using Flask on pythonanywhere.com. However when I put the following line in the code for the web app I get an error:
solr = Solr('http://localhost:8983/solr/techproducts')
The error that I am getting is:
pysolr.SolrError: Failed to connect to server at http://localhost:8983/solr/techproducts/select/?q=Sumedh&wt=json: HTTPConnectionPool(host='localhost', port=8983): Max retries exceeded with url: /solr/techproducts/select/?q=Sumedh&wt=json (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fa57c3c28d0>: Failed to establish a new connection: [Errno 111] Connection refused',))
If someone can please help me in solving this error I would be really grateful.

Connecting to Could SQL from local machine via proxy

I am following these instructions to deploy a Django app on Google App Engine:
https://cloud.google.com/python/django/appengine
I have got as far as downloading the proxy .exe file (I am on a Windows machine) and connecting to it:
2019/01/08 16:14:08 Listening on 127.0.0.1:3306 for
[INSTANCE-NAME] 2019/01/08 16:14:08
Ready for new connections
When I try and create the Django migrations by running python manage.py createmigrations I see the connection received by the proxy file:
2019/01/08 16:15:06 New connection for
"[INSTANCE-NAME]"
However, after a couple of seconds pause I get this error:
2019/01/08 16:15:28 couldn't connect to
"[INSTANCE-NAME]": dial tcp
35.205.185.133:3307: connectex: 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.
I have tried disabling my local firewall in case this was causing any issues, but the result is the same. I've also checked the username, password and Cloud SQL instance name, they are all correct.
What could be causing this error?

python2 sockets can't connect to python3 sockets

I was trying to code a simple server client program in python and when i ran the server using python3 and tried to have the client connect to it using python2, it would throw an error:
TimeoutError: [WinError 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
however, when i ran the same short program on the same computer using python2 and python3, it would connect. The 2 separate computers would only connect if they were using the same version of python. Is there a reason for this and a way around this?
#client
s=socket.socket()
s.connect(('ip, port))
#server
s=socket()
s.bind(('', port))
s.listen(4)
c, addr = s.accept()
Your Windows software firewall has python.exe marked as allowed but not python3.exe.

Python 2.7 : socket.error error [Errno 111] - connection refused

I created a TCP server program (see server.py) to access the terminal of another computer (see client.py). When I use the client and server locally (only on my computer) everything is fine, however when the client is sending a request from a different computer, I receive this message on the client side :
Traceback (most recent call last):
File "client.py", line 11, in <module>
client.connect((serverIP, serverPort))
File "/usr/lib/python2.7/socket.py", line 228, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused
Note : the server is the computer which is being accessed by the client.
'Connection refused' means there was nothing listening at the IP:port you tried to connect to.
It comes from the target system, which means that the connection request got there and the refusal came back, so it isn't a firewall issue.
Solved it. I had to use the IP given to in when running ifconfig (192.168.1.***). I was binding to localhost, and thus I could not connect to the server remotely.