dyyce

dyyce

Failed WebSocket handshake after deploying with phoenix 1.3 and edeliver

Hello :slight_smile:

I’ve got a weird websocket error when I deploy my app using edeliver:

WebSocket connection to 'ws://staging.cur-vita.com/socket/websocket?token=undefined&vsn=2.0.0' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

I do not know what went wrong, everything is working fine locally (both dev and prod env).
Did anybody had a similar error?

My prod config:

config :curvita, CurvitaWeb.Endpoint,
  http: [port: 4000],
  url: [host: "localhost", port: 80],
  check_origin: true,
  cache_static_manifest: "priv/static/cache_manifest.json",
  server: true,
  root: ".",
  version: Mix.Project.config[:version]

# Do not print debug messages in production
config :logger, level: :info
config :curvita, :environment, :prod

my edeliver config is:

APP="curvita"

BUILD_HOST="staging.cur-vita.com"
BUILD_USER="deploy"
BUILD_AT="/tmp/edeliver/$APP/builds"

RELEASE_DIR="/tmp/edeliver/$APP/builds/_build/prod/rel/$APP"

# prevent re-installing node modules; this defaults to "."
GIT_CLEAN_PATHS="_build rel priv/static"

# STAGING_HOSTS="188.166.182.170"
# STAGING_USER="deploy"
# TEST_AT="/home/deploy/staging"

PRODUCTION_HOSTS="staging.cur-vita.com"
PRODUCTION_USER="deploy"
DELIVER_TO="/home/deploy"

# For *phx* projects, symlink prod.secret.exs to our tmp source
pre_erlang_get_and_update_deps() {
  local _prod_secret_path="/home/deploy/prod.secret.exs"
  if [ "$TARGET_MIX_ENV" = "prod" ]; then
    __sync_remote "
      ln -sfn '$_prod_secret_path' '$BUILD_AT/config/prod.secret.exs'
    "
  fi
}

pre_erlang_clean_compile() {
  status "Running phx.digest" # log output prepended with "----->"
  __sync_remote " # runs the commands on the build host
    # [ -f ~/.profile ] && source ~/.profile # load profile (optional)
    source ~/.profile
    
    # echo \$PATH # check if rbenv is in the path
    set -e # fail if any command fails (recommended)
    cd '$BUILD_AT' # enter the build directory on the build host (required)

    # prepare something
    mkdir -p priv/static # required by the phx.digest task
    cd ./assets

    npm install 

    ./node_modules/.bin/webpack -p

    cd ../

    # run your custom task
    APP='$APP' MIX_ENV='$TARGET_MIX_ENV' $MIX_CMD phx.digest $SILENCE
  "
}

Cheers

Marked As Solved

Gazler

Gazler

Phoenix Core Team

@dyyce If you are running on port 4000 and it works on port 4000, then I assume you have some sort of reverse proxy (nginx, haproxy, etc) running on port 80? In that case, it is certainly worth checking that the websockets aren’t being stopped at that level.

NGINX | F5 describes the process for nginx

Also Liked

Gazler

Gazler

Phoenix Core Team

You should also have an error in your logs from Phoenix that looks like:

https://github.com/phoenixframework/phoenix/blob/6854cd497a7ca9ed2c7a8e43198d4edcfb966137/lib/phoenix/socket/transport.ex#L399L417

If you follow the instructions in there then it should resolve your issue.

Specifically changing:

url: [host: "localhost", port: 80],

to

url: [host: "staging.cur-vita.com", port: 80],

Where Next?

Popular in Questions Top

nobody
How to bind a phoenix app to a specific ip address? could not find anything about that, nowhere, unfortunately, but for me this is quite...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vac
Hi, I’m quite new in Elixir and I’m trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and I...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement