On Mar 2, 2018, at 15:42, jonas.grave@me.com wrote:
Sorry, I am not so good at this network syntax.... From other bokeh apps/scripts I have worked on I have figured out using the --allow-websocket-orign=ip:port when I run the bokeh serve command.
However, in this case I try to generate a html file with the link to the server embedded (without Flask). Hence, one points a browser to a file://<name_of_file.html> (the reason for doing it this way is just the way the framework is where I'll try and use it)
The only way I could the the bokeh server to allow the embedded link to read the server doc was by using --allow-websocket-origin=*
If I use bokeh serve sliders.py --allow-websocket-origin='file:///xxxxx/xxx/sliders_embed.html' I get an error: ERROR:Invalid port in host value: file:///xxxxx/xxx/sliders_embed.html
Jonas
Den lørdag den 3. marts 2018 kl. 00.13.59 UTC+1 skrev Bryan Van de ven:
That will certainly work, but note that it will allow WS connections from anywhere. If you can be more specific than that, I would recommend it. Generally speaking, the value should be URL that users will navigate to, i.e. the "Origin" (you can add multiple on the command line too, if needed)
Thanks,
Bryan
> On Mar 2, 2018, at 15:11, jonas...@me.com wrote:
>
> Of course... I needed to use --allow-websocket-origin=* in order to get to work. Thanks!
>
> Jonas
>
> Den fredag den 2. marts 2018 kl. 21.18.05 UTC+1 skrev Bryan Van de ven:
> Hi,
>
> You need to tell the Bokeh server to accept WebSocket connections from whatever the URL of the embedding page is. By default the Bokeh server is conservative and does not allow arbitrary connections. As the console error message mentions, you can use --allow-websocket-origin to specify allowed origin URLs when you run "bokeh serve"
>
> Thanks,
>
> Bryan
>
> > On Mar 2, 2018, at 07:52, jonas...@me.com wrote:
> >
> > Hi,
> >
> > I'm trying to embed a running app from bokeh server into a html page without the use of Flask. I'm able to get the script into the <body> part of the Jinja2 template, but connection is refused when I open the created html file. The error I get is:
> >
> > 2018-03-02 16:42:32,788 Refusing websocket connection from Origin 'file://'; use --allow-websocket-origin= to permit this; currently we allow origins set(['localhost:5003'])
> > 2018-03-02 16:42:32,789 403 GET /sliders/ws?bokeh-protocol-version=1.0&bokeh-session-id=Zjq1aabS166yeI0nYIyNDCFBq321SiqJr8OnT0rN5X1Z (::1) 1.27ms
> >
> > Part of Chromium console output
> > [bokeh] Will inject Bokeh script tag with params {"elementid":"6c319794-5d7d-4b98-b105-d290f63fb309","sessionid":"Zjq1aabS166yeI0nYIyNDCFBq321SiqJr8OnT0rN5X1Z","use_for_title":false}
> > autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:113 Bokeh: injecting CSS: http://localhost:5003/static/css/bokeh.min.css?v=40d5c9a6441908ce9b812db9e82be4d5
> > autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:115 Bokeh: injecting CSS: http://localhost:5003/static/css/bokeh-widgets.min.css?v=509e292d9a7ef7e9eb8382fcde7b4a6e
> > autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:117 Bokeh: injecting CSS: http://localhost:5003/static/css/bokeh-tables.min.css?v=aa783ffa4e290813a295a99cce2f8b5d
> > autoload.js?bokeh-autoload-element=6c319794-5d7d-4b98-b105-d290f63fb309&bokeh-app-path=/sliders&bokeh-absolute-url=http://localhost:5003/sliders:27 Bokeh: all callbacks have finished
> >
> >
> >
> > My script for running and making the html document is as follows:
> >
> > import io
> >
> >
> >
> >
> > from jinja2 import Template
> >
> >
> > from bokeh.plotting import figure
> > from bokeh.resources import INLINE
> > from bokeh.embed import file_html, server_document, server_session
> > from bokeh.client import pull_session
> >
> >
> >
> >
> > TEMPLATE = Template('''
> > <!DOCTYPE html>
> > <html lang="en">
> > <head>
> > <meta charset="utf-8">
> >
> > </head>
> > <body>
> >
> >
> > <h1>Header</h1>
> > <p>Test embed slider.py</p>
> >
> >
> > {{ script|safe }}
> >
> >
> > </body>
> > </html>
> > '''
> > )
> >
> >
> > url = 'http://localhost:5003/sliders'
> > #session = pull_session(url=url)
> > #script = server_session(None, session.id, url=url)
> > script = server_document(url)
> >
> >
> > html = TEMPLATE.render(script = script)
> > with io.open("sliders_embed.html", mode='w+', encoding='utf-8') as f:
> > f.write(html)
> >
> > Hence when I view sliders_embed.html in the browser I get the error stated in the beginning. I have tried using server_document or a combination of pull_session and server_session, but it gives the same error.
> >
> > Any help would be appreciated. Thanks.
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/d0f6eb7b-e4f9-4b8e-a272-c821f85c1e7d%40continuum.io\.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/dad2b19e-fb4a-48f4-9420-52e383050011%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+unsubscribe@continuum.io.
To post to this group, send email to bokeh@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/3cd402fb-b037-4321-9443-deb6e663d72b%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.