Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Connection refused error #26

Closed
thomasjhuang opened this issue Feb 19, 2020 · 9 comments
Closed

Connection refused error #26

thomasjhuang opened this issue Feb 19, 2020 · 9 comments

Comments

@thomasjhuang
Copy link

I'm getting an issue that looks like this when I'm trying to save a relatively large chart. I get this error when using either the node backend or the selenium backend (correctly installed all dependencies according to the readme). What could cause this problem? This only happens on the call to save(summary_graph,'summary_graph.png') where summary_graph is of type altair.vegalite.v4.api.HConcatChart.

ConnectionRefusedError                    Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/urllib3/connection.py in _new_conn(self)
    156             conn = connection.create_connection(
--> 157                 (self._dns_host, self.port), self.timeout, **extra_kw
    158             )

/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     83     if err is not None:
---> 84         raise err
     85 

/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     73                 sock.bind(source_address)
---> 74             sock.connect(sa)
     75             return sock

ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    671                 headers=headers,
--> 672                 chunked=chunked,
    673             )

/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    386         else:
--> 387             conn.request(method, url, **httplib_request_kw)
    388 

/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1243         """Send a complete request to the server."""
-> 1244         self._send_request(method, url, body, headers, encode_chunked)
   1245 

/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1289             body = _encode(body, 'body')
-> 1290         self.endheaders(body, encode_chunked=encode_chunked)
   1291 

/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in endheaders(self, message_body, encode_chunked)
   1238             raise CannotSendHeader()
-> 1239         self._send_output(message_body, encode_chunked=encode_chunked)
   1240 

/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in _send_output(self, message_body, encode_chunked)
   1025         del self._buffer[:]
-> 1026         self.send(msg)
   1027 

/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py in send(self, data)
    965             if self.auto_open:
--> 966                 self.connect()
    967             else:

/usr/local/lib/python3.7/site-packages/urllib3/connection.py in connect(self)
    183     def connect(self):
--> 184         conn = self._new_conn()
    185         self._prepare_conn(conn)

/usr/local/lib/python3.7/site-packages/urllib3/connection.py in _new_conn(self)
    168             raise NewConnectionError(
--> 169                 self, "Failed to establish a new connection: %s" % e
    170             )

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x147bf2a90>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
<ipython-input-147-2a814c35573f> in <module>
----> 1 save(label_summary_graph,'summary_graph.png')

/usr/local/lib/python3.7/site-packages/altair_saver/_core.py in save(chart, fp, fmt, mode, method, **kwargs)

/usr/local/lib/python3.7/site-packages/altair_saver/savers/_saver.py in save(self, fp, fmt)

/usr/local/lib/python3.7/site-packages/altair_saver/savers/_saver.py in mimebundle(self, fmts)

/usr/local/lib/python3.7/site-packages/altair_saver/savers/_selenium.py in _mimebundle(self, fmt)

/usr/local/lib/python3.7/site-packages/altair_saver/savers/_selenium.py in _extract(self, fmt)

/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in get(self, url)
    331         Loads a web page in the current browser session.
    332         """
--> 333         self.execute(Command.GET, {'url': url})
    334 
    335     @property

/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py in execute(self, driver_command, params)
    317 
    318         params = self._wrap_value(params)
--> 319         response = self.command_executor.execute(driver_command, params)
    320         if response:
    321             self.error_handler.check_response(response)

/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py in execute(self, command, params)
    372         data = utils.dump_json(params)
    373         url = '%s%s' % (self._url, path)
--> 374         return self._request(command_info[0], url, body=data)
    375 
    376     def _request(self, method, url, body=None):

/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/remote_connection.py in _request(self, method, url, body)
    395 
    396         if self.keep_alive:
--> 397             resp = self._conn.request(method, url, body=body, headers=headers)
    398 
    399             statuscode = resp.status

/usr/local/lib/python3.7/site-packages/urllib3/request.py in request(self, method, url, fields, headers, **urlopen_kw)
     78         else:
     79             return self.request_encode_body(
---> 80                 method, url, fields=fields, headers=headers, **urlopen_kw
     81             )
     82 

/usr/local/lib/python3.7/site-packages/urllib3/request.py in request_encode_body(self, method, url, fields, headers, encode_multipart, multipart_boundary, **urlopen_kw)
    169         extra_kw.update(urlopen_kw)
    170 
--> 171         return self.urlopen(method, url, **extra_kw)

/usr/local/lib/python3.7/site-packages/urllib3/poolmanager.py in urlopen(self, method, url, redirect, **kw)
    328             response = conn.urlopen(method, url, **kw)
    329         else:
--> 330             response = conn.urlopen(method, u.request_uri, **kw)
    331 
    332         redirect_location = redirect and response.get_redirect_location()

/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    760                 release_conn=release_conn,
    761                 body_pos=body_pos,
--> 762                 **response_kw
    763             )
    764 

/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    760                 release_conn=release_conn,
    761                 body_pos=body_pos,
--> 762                 **response_kw
    763             )
    764 

/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    760                 release_conn=release_conn,
    761                 body_pos=body_pos,
--> 762                 **response_kw
    763             )
    764 

/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    718 
    719             retries = retries.increment(
--> 720                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    721             )
    722             retries.sleep()

/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    434 
    435         if new_retry.is_exhausted():
--> 436             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    437 
    438         log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)

MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=61028): Max retries exceeded with url: /session/cd2aa6c78fe58e790b74bd08e7eb0653/url (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x147bf2a90>: Failed to establish a new connection: [Errno 61] Connection refused'))
@jakevdp
Copy link
Member

jakevdp commented Feb 19, 2020

Thanks for the report. I can't reproduce this and I don't have any guesses as to what may be causing it. Please let me know if you are able to debug the issue.

@jakevdp
Copy link
Member

jakevdp commented Feb 19, 2020

Oh, maybe one guess: does your chart use data from an external URL?

@thomasjhuang
Copy link
Author

thomasjhuang commented Feb 19, 2020

No, my chart doesn't use data from an external URL, this issue is happening from chart data that comes directly from a csv that I parsed into a DataFrame on my local machine. I wasn't able to resolve that issue, but after reinstalling all dependencies into a conda environment and switching to python 3.8, this problem went away.

@zit-cat
Copy link

zit-cat commented May 22, 2020

I also have this problem and I also don't use external data.

One thing that I don't know if it is related is that I have had problem installing portpicker just a few days earlier (#25). At that time I didn't reinstall everything and I forgot how I fixed it. Saving charts worked for at least some time but now after a kernel restart it failed with ConnectionRefusedError. Since portpicker is responsible finding for available network ports and this issue is related to creating a new connection to a port I thought they might be related.

@zacharylawrence
Copy link

I also get this problem semi-regularly despite not intentionally making any network calls. Restarting my Jupyter kernel temporarily fixes this.

@zacharylawrence
Copy link

For me, it seems like this might be triggered when the jupyter kernel gets interrupted (not stopped) and then a new altair command is issued? I can try to more rigorously test this in the future.

@JohnBurant
Copy link

I'm having the same problem saving ConcatChart objects using chart.save(filename.xyz). First time. Occurs when saving as PNG or SVG but works fine when saving as HTML. However, PNG and SVG files are generated just fine when I click on the ... in the chart. Working in JupyterLab.

@JohnReid
Copy link

For me, it seems like this might be triggered when the jupyter kernel gets interrupted (not stopped) and then a new altair command is issued? I can try to more rigorously test this in the future.

Same here.

@joelostblom
Copy link
Member

Since Altair 5.2, the functionality of Altair Saver is now available in Altair via the vl-convert package. Most of the functionality has been available since 5.0, and the main addition in 5.2 was PDF export. See the docs on how to save charts for more details.

We are going to archive this repo, so I'm closing all the open issues and PRs before doing so. Try out the new options for saving charts mentioned above and if you run into issues, please open an issue directly in the altair or vl-convert repo.

@joelostblom joelostblom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants