Thanks to visit codestin.com
Credit goes to github.com

Skip to content

127.0.0.1 hardcoded in webagg backend server #13055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
thedch opened this issue Dec 26, 2018 · 2 comments · Fixed by #13065
Closed

127.0.0.1 hardcoded in webagg backend server #13055

thedch opened this issue Dec 26, 2018 · 2 comments · Fixed by #13065
Milestone

Comments

@thedch
Copy link

thedch commented Dec 26, 2018

Bug report

Bug summary

Hardcoded URL in webagg backend is misleading and sometimes wrong

Code for reproduction

import matplotlib as mpl
mpl.use('WebAgg')
import matplotlib.pyplot as plt
import numpy as np

mpl.rcParams['webagg.open_in_browser'] = False
fig, plot = plt.subplots(nrows=1)
plot.imshow(np.random.rand(224,224,3))
plt.show()

Actual outcome

To view figure, visit http://127.0.0.1:8988
Press Ctrl+C to stop WebAgg server

Expected outcome

Hopefully something like

To view figure, visit http://[insert my server IP here]:8988
Press Ctrl+C to stop WebAgg server

Matplotlib version

  • Operating system: Ubuntu 16.04
  • Matplotlib version: 2.0.2
  • Matplotlib backend (print(matplotlib.get_backend())): WebAgg
  • Python version: 3.6.1
  • Jupyter version (if applicable):
  • Other libraries:

Basically, it'd be nice to have control over what IP gets printed there, instead of hard coding localhost -- https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_webagg.py#L324 -- maybe add another key to rcParams? (and leave localhost as the default?)

@anntzer
Copy link
Contributor

anntzer commented Dec 29, 2018

Shouldn't we print rcParams["webagg.address"] here? Not that I know anything about IPs...

@tacaswell
Copy link
Member

To test that this works locally, try something like:

import matplotlib as mpl
import netifaces
import numpy as np

mpl.use('WebAgg')
import matplotlib.pyplot as plt


mpl.rcParams['webagg.open_in_browser'] = False
mpl.rcParams['webagg.address'] = netifaces.ifaddresses('wlp4s0')[netifaces.AF_INET][0]['addr']
fig, plot = plt.subplots(nrows=1)
plot.imshow(np.random.rand(224, 224, 3))
plt.show()

I am hesitant to put this in the test suite as hard-coding any other ip address or interface name than 127.0.0.1 into the tests seems like it will be very brittle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants