Web UI exec connection error

Hi. I get an intermittent error when using the “Exec” feature of the Nomad UI (v1.0.2):

Select a task to start your session.

Multiple instances of this task are running. The allocation below was selected by random draw.

Customize your command, then hit ‘return’ to run.

$ nomad alloc exec -i -t -task grafana 451837c8 /bin/ash

The connection has closed.

After ~10 hard refreshes of the window, it eventually works. When I execute nomad alloc exec -i -t -task grafana 451837c8 /bin/ash in my local terminal, it consistently succeeds. Anyone know what could be going wrong, or how I can better troubleshoot this issue? Could it be related to Firefox and Websockets?

hmm… it’s hard to know whether Firefox is part of the problem, but could you try in another browser to see if it makes a difference? What platform are you on?

Another thing to check would be what’s being passed through the WebSocket. Maybe there’s a frame that shows an error code that closes the socket?

I think I figured it out. The connection was being blocked by Firefox.

https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor/request_details#Timings

Navigating to about:config and increasing the http.max-persistent-connections-per-server value seems to have worked!

oh interesting, I wonder if that’s causing problems for others though :flushed: thanks for sharing the diagnosis!

Hi.
Face the same problem with Nomad v1.2.2. Fails in all browsers (Firefox, Edge, Chrome).
Don’t think that fails because of timeout. Tried both: routed through Nginx reverse proxy and directly - nothing changes.
As in original post - when connecting to Nomad server via ssh everything works perfectly. But WEB UI fails all the time.
Any suggestions?

Sorry. That’s Nginx. :slight_smile: And Firefox also. :slight_smile:

If somebody faces the same problem just add additional location to Your reverse proxy configuration:

    location /v1/client/allocation {
        proxy_pass http://nomad-server-dev;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

Please don’t forget to change an upstream name. :wink: