Dash and ZMQ "address already in use"

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