SimonDanisch / Bonito.jl

Serving JS to the browser
MIT License
205 stars 30 forks source link

It is not possible to call Page in two different Pluto notebooks at the same time #109

Closed diegozea closed 2 years ago

diegozea commented 2 years ago

Hi!

It is not possible to call Page in two different Pluto notebooks at the same time. When you try to call Page() in the second one, the following error appears:

image

begin
    using JSServe
    Page()
end

Is it possible to make each notebook automatically use a different address?

Best,

Failed to show value:

IOError: listen: address already in use (EADDRINUSE)

uv_error@libuv.jl:97[inlined]
#listen#13@Sockets.jl:632[inlined]
#listen#10@Sockets.jl:625[inlined]
listen@Sockets.jl:623[inlined]
var"#start#24"(::Bool, ::typeof(JSServe.start), ::JSServe.Server)@server.jl:296
var"#Server#18"(::Bool, ::JSServe.Routes, ::JSServe.Routes, ::Type{JSServe.Server}, ::JSServe.App, ::String, ::Int64)@server.jl:232
get_server()@server.jl:311
show(::IOContext{IOBuffer}, ::MIME{Symbol("text/html")}, ::JSServe.Page)@display.jl:89
show_richest(::IOContext{IOBuffer}, ::Any)@PlutoRunner.jl:795
var"#sprint_withreturned#32"(::IOContext{Base.DevNull}, ::Int64, ::typeof(Main.PlutoRunner.sprint_withreturned), ::Function, ::JSServe.Page)@PlutoRunner.jl:732
format_output_default(::Any, ::Any)@PlutoRunner.jl:656
#format_output#21@PlutoRunner.jl:673[inlined]
formatted_result_of(::Base.UUID, ::Bool, ::Nothing, ::Module)@PlutoRunner.jl:589
top-level scope@none:1
SimonDanisch commented 2 years ago

You need to set listen_port to some different numbers

diegozea commented 2 years ago

Thanks! I wondered if that could be done automatically by JSServe. Otherwise, It could be great if the error message could suggest that fix. Best,

SimonDanisch commented 2 years ago

Yeah, i've put quite a bit of thought into this, but couldn't find a method to reliably find blocked ports cross platform. And the error also doesn't get thrown reliably, so it may just hang, so I also can't throw a better error... If you find any way to improve the situation let me know!