dyyce
Failed WebSocket handshake after deploying with phoenix 1.3 and edeliver
Hello ![]()
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
@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
You should also have an error in your logs from Phoenix that looks like:
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],
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









