insidesherpa / JPMC-tech-task-1-PY3

50 stars 447 forks source link

Client3.py not working #233

Open gauravgarg2002 opened 2 years ago

gauravgarg2002 commented 2 years ago

Throwing this error


ConnectionRefusedError Traceback (most recent call last) /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1345 try: -> 1346 h.request(req.get_method(), req.selector, req.data, headers, 1347 encode_chunked=req.has_header('Transfer-encoding'))

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py in request(self, method, url, body, headers, encode_chunked) 1256 """Send a complete request to the server.""" -> 1257 self._send_request(method, url, body, headers, encode_chunked) 1258

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py in _send_request(self, method, url, body, headers, encode_chunked) 1302 body = _encode(body, 'body') -> 1303 self.endheaders(body, encode_chunked=encode_chunked) 1304

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py in endheaders(self, message_body, encode_chunked) 1251 raise CannotSendHeader() -> 1252 self._send_output(message_body, encode_chunked=encode_chunked) 1253

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py in _send_output(self, message_body, encode_chunked) 1011 del self._buffer[:] -> 1012 self.send(msg) 1013

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py in send(self, data) 951 if self.auto_open: --> 952 self.connect() 953 else:

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py in connect(self) 922 """Connect to the host and port specified in init.""" --> 923 self.sock = self._create_connection( 924 (self.host,self.port), self.timeout, self.source_address)

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py in create_connection(address, timeout, source_address) 842 try: --> 843 raise err 844 finally:

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py in create_connection(address, timeout, source_address) 830 sock.bind(source_address) --> 831 sock.connect(sa) 832 # Break explicitly a reference cycle

ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

URLError Traceback (most recent call last) /var/folders/zz/nzr065396cd8sr6f_4n1xhjh0000gn/T/ipykernel24228/3703086970.py in 50 # Query the price once every N seconds. 51 for in iter(range(N)): ---> 52 quotes = json.loads(urllib.request.urlopen(QUERY.format(random.random())).read()) 53 54 """ ----------- Update to get the ratio --------------- """

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 212 else: 213 opener = _opener --> 214 return opener.open(url, data, timeout) 215 216 def install_opener(opener):

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in open(self, fullurl, data, timeout) 515 516 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) --> 517 response = self._open(req, data) 518 519 # post-process response

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in _open(self, req, data) 532 533 protocol = req.type --> 534 result = self._call_chain(self.handle_open, protocol, protocol + 535 '_open', req) 536 if result:

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in _call_chain(self, chain, kind, meth_name, args) 492 for handler in handlers: 493 func = getattr(handler, meth_name) --> 494 result = func(args) 495 if result is not None: 496 return result

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in http_open(self, req) 1373 1374 def http_open(self, req): -> 1375 return self.do_open(http.client.HTTPConnection, req) 1376 1377 http_request = AbstractHTTPHandler.dorequest

/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1347 encode_chunked=req.has_header('Transfer-encoding')) 1348 except OSError as err: # timeout error -> 1349 raise URLError(err) 1350 r = h.getresponse() 1351 except:

URLError: <urlopen error [Errno 61] Connection refused>