-
Notifications
You must be signed in to change notification settings - Fork 42
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
with_logger(NullLogger()) breaks MeshCat #68
Comments
Uh, fascinating. Yeah, I think this is just a symptom of some broader issues with deciding when to be synchronous vs. asynchronous. I'll take a look at this issue specifically, though. |
Alright, so Line 5 in d93d0a7
calls |
I think we might still need the I wonder if we could copy that |
This seems to work, and might be a suitable replacement for using WebIO
using WebSockets
using Mux
using HTTP
using Sockets
app = Mux.page("/", req -> "hello")
http = Mux.App(Mux.mux(Mux.defaults, app, Mux.notfound()))
websock = Mux.App(Mux.mux(
Mux.wdefaults,
Mux.route("/webio-socket", WebIO.create_socket),
Mux.wclose,
Mux.notfound(),
))
server = WebSockets.ServerWS(Mux.http_handler(http), Mux.ws_handler(websock))
host = Mux.localhost
function serve(server::WebSockets.ServerWS{T, H, W}, host, port, verbose) where {T, H, W}
tcpserver = Ref(Sockets.listen(Sockets.InetAddr(host, port)))
@async begin
take!(server.in)
close(tcpserver[])
end
function _servercoroutine(stream::HTTP.Stream)
try
if WebSockets.is_upgrade(stream.message)
WebSockets.upgrade(server.wshandler.func, stream)
else
WebSockets.handle_request(server.handler.func, stream)
end
catch err
put!(server.out, err)
put!(server.out, stacktrace(catch_backtrace()))
end
end
@async HTTP.listen(_servercoroutine,
host, port;
tcpref=tcpserver,
ssl=(T == HTTP.Servers.https),
sslconfig = server.options.sslconfig,
verbose = verbose,
tcpisvalid = server.options.ratelimit > 0 ? checkratelimit! :
(tcp; kw...) -> true,
ratelimits = Dict{IPAddr, HTTP.Servers.RateLimit}(),
ratelimit = server.options.ratelimit)
return tcpserver[]
end
port = 8004
tcpserver = serve(server, host, port, false)
run(`xdg-open http://localhost:$port`) |
Ah right. I was assuming that the I'm a little bit worried about this being brittle; it's quite a bit of additional code that we need to keep in sync with the WebIO stack. But maybe that's just what's needed. Another option could be to open a few PRs against various web stack packages (man there's a lot of them). Does this really work by the way? Since the I was wondering if we could just use the first argument to |
Yeah, I'd prefer to get this into WebSockets instead of having to maintain it ourselves, but we can at least try it out and see if it works. I think this should work, although we might need to wait until |
Oh yeah, I hadn't noticed you'd changed that. |
I wanted to make MeshCat/the web stack a little less verbose, so I tried using
with_logger(NullLogger())
:Unfortunately, only the first time I run
open(vis)
, I getIf I reload the browser tab, it's fine. Should
open
include await
or something?The text was updated successfully, but these errors were encountered: