Dash and ZMQ "address already in use"

Puzzled by this error message as nothing is running on the port for Dash (I run sudo netstat -nlp to make sure) and the ZMQ is working, on it’s own, perfectly as is the Dash functionality. Put them together, which doesn’t seem unreasonable, and they should work well. I don’t see how the bindings are causing the issue.

I’m using linux and I was told that ZMQ and Dash are using the same port. My problem is that I don’t know how to address this issue. I have tried changed the port numbers but same results

here’s the error

ave@deepthought:~/tontine_2022/just_messing$ julia 6_25_min_dash.jl 
starting IN Socket 5555
Received request: END
dying
ERROR: LoadError: TaskFailedException
Stacktrace:
 [1] wait
   @ ./task.jl:334 [inlined]
 [2] hot_restart(func::Dash.var"#72#74"{Dash.DashApp, String, Int64}; check_interval::Float64, env_key::String, suppress_warn::Bool)
   @ Dash ~/.julia/packages/Dash/yscRy/src/utils/hot_restart.jl:23
 [3] run_server(app::Dash.DashApp, host::String, port::Int64; debug::Bool, dev_tools_ui::Nothing, dev_tools_props_check::Nothing, dev_tools_serve_dev_bundles::Nothing, dev_tools_hot_reload::Nothing, dev_tools_hot_reload_interval::Nothing, dev_tools_hot_reload_watch_interval::Nothing, dev_tools_hot_reload_max_retry::Nothing, dev_tools_silence_routes_logging::Nothing, dev_tools_prune_errors::Nothing)
   @ Dash ~/.julia/packages/Dash/yscRy/src/server.jl:64
 [4] build_dash()
   @ Main ~/tontine_2022/just_messing/6_25_min_dash.jl:46
 [5] top-level scope
   @ ~/tontine_2022/just_messing/6_25_min_dash.jl:68

    nested task error: LoadError: StateError("Address already in use")
    Stacktrace:
     [1] bind(socket::Socket, endpoint::String)
       @ ZMQ ~/.julia/packages/ZMQ/R3wSD/src/socket.jl:58
     [2] top-level scope
       @ ~/tontine_2022/just_messing/6_25_min_dash.jl:10
     [3] include(mod::Module, _path::String)
       @ Base ./Base.jl:418
     [4] include(x::String)
       @ Main.##274 ~/.julia/packages/Dash/yscRy/src/utils/hot_restart.jl:21
     [5] top-level scope
       @ ~/.julia/packages/Dash/yscRy/src/utils/hot_restart.jl:21
     [6] eval
       @ ./boot.jl:373 [inlined]
     [7] eval
       @ ./Base.jl:68 [inlined]
     [8] (::Dash.var"#21#22"{String, Symbol})()
       @ Dash ./task.jl:423
    in expression starting at /home/dave/tontine_2022/just_messing/6_25_min_dash.jl:10
in expression starting at /home/dave/tontine_2022/just_messing/6_25_min_dash.jl:68
dave@deepthought:~/tontine_2022/just_messing$ 

can someone look at my code to see what I am doing wrong please?

here’s the ZMQ pull code

using ZMQ
using Dash
using DataFrames


context = Context()

in_socket = Socket(context, PULL)

ZMQ.bind(in_socket, "tcp://*:5555")

println("starting IN Socket 5555")


dash_columns = ["sym","price","sdmove","hv20","hv10","hv5","iv","iv%ile","prc%ile","volume"]
 
df_dash_table = DataFrame([col => (col == "sym" ? String : Float64)[] for col in dash_columns ])



function build_dash()

app = dash()

app.layout = html_div() do
             html_h1("tontine2"),
             dash_datatable( id="table", columns=[Dict("name" =>i, "id" => i) for i in names(df_dash_table)],
             data = Dict.(pairs.(eachrow(df_dash_table))),
                          editable=false,
                          filter_action="native",
                          sort_action="native",
                          sort_mode="multi",
                          row_selectable="multi",
                          row_deletable=false,
                          selected_rows=[],
                     ##   page_action="native",
                     ##   page_current= 0,
                     ##   page_size= 10,
 
                           )#end dash_datatable 

                           
end


run_server(app, "0.0.0.0", debug=true)

end




while true
              
   message = String(ZMQ.recv(in_socket))

   println("Received request: $message")

   if message == "END"
      println("dying")
      break
   end


end


build_dash()

and here’s the code to trigger the event

using ZMQ

context = Context()

stk_socket = Socket(context, PUSH)

ZMQ.connect(stk_socket, "tcp://localhost:5555")

ZMQ.send(stk_socket,"END")

ZMQ.close(stk_socket)

ZMQ.close(context)

this wonderful solution was provided in another forum.

using ZMQ
using Dash
using Distributed


app = dash(external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"])

app.layout = html_div() do
        html_h1("Hello Dash"),
        html_div("Dash.jl: Julia interface for Dash"),
        dcc_graph(
            id = "example-graph",
            figure = (
                data = [
                    (x = [1, 2, 3], y = [4, 1, 2], type = "bar", name = "SF"),
                    (x = [1, 2, 3], y = [2, 4, 5], type = "bar", name = "Montréal"),
                ],
                layout = (title = "Dash Data Visualization",)
            )
        )
    end

@spawn run_server(app, "0.0.0.0", 8080)


function testpush()
    context = Context()
    stk_socket = Socket(context, PUSH)
    ZMQ.connect(stk_socket, "tcp://localhost:5555")
    ZMQ.send(stk_socket,"END")
    ZMQ.close(stk_socket)
    ZMQ.close(context)
end

context = Context()
in_socket = Socket(context, PULL)
ZMQ.bind(in_socket, "tcp://*:5555")
sleep(1)
@spawn testpush()
sleep(5)
1 Like