bosko

bosko

I am using Ecto Tds to connect to MS SQL server and till today everything worked fine. I am developing on OS X and deploying application on EC2 instance with Ubuntu 20.04. I build release in Docker with following Dockerfile

FROM ubuntu:20.04 as production-environment
ENV LANG=en_US.UTF-8
ENV DEBIAN_FRONTEND noninteractive

RUN \
  apt-get update -y && \
  apt-get install -y git curl wget locales gnupg2 build-essential && \
  locale-gen en_US.UTF-8 && \
  wget https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb && \
  dpkg -i erlang-solutions_2.0_all.deb && \
  rm erlang-solutions_2.0_all.deb && \
  apt-get update -y && \
  apt-get install -y esl-erlang elixir

CMD ["/bin/bash"]

FROM production-environment as build

# ===========
# Application
# ===========

# prepare build dir
WORKDIR /app

# set build ENV
ENV MIX_ENV=prod

ENV SECRET_KEY_BASE=fake

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8

# install hex + rebar
RUN mix local.hex --force && \
    mix local.rebar --force

# install mix dependencies
COPY mix.exs mix.lock ./
RUN mix deps.get --only $MIX_ENV
RUN mkdir config

# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile

COPY priv priv

COPY lib lib

COPY assets assets

# build assets
run mix assets.deploy

# compile and build release
RUN mix compile

# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/

COPY rel rel
RUN mix release

FROM scratch AS app

WORKDIR /app
COPY --from=build /app/_build/prod/*.tar.gz ./

CMD ["/bin/bash"]

Today suddenly after deploying new version application stopped working with following error:

[error] GenServer #PID<0.697.0> terminating                                                                       
** (ArgumentError) errors were found at the given arguments:                              
                                                         
  * 1st argument: not a port                                                                                      
                                                                                                                  
    :erlang.port_info(#PID<0.711.0>, :connected)                                                                  
    (elixir 1.13.0) lib/port.ex:273: Port.info/2     
    (tds 2.3.0) lib/tds/tls.ex:86: Tds.Tls.assert_connected!/1
    (tds 2.3.0) lib/tds/tls.ex:41: Tds.Tls.send/2                                                                 
    (tds 2.3.0) lib/tds/tls.ex:209: Tds.Tls.handle_info/2 
    (stdlib 4.0) gen_server.erl:1120: :gen_server.try_dispatch/4                                                                                                                                                                     
    (stdlib 4.0) gen_server.erl:1197: :gen_server.handle_msg/6                                                    
    (stdlib 4.0) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:tcp_closed, #Port<0.46>}
State: %Tds.Tls{buffer: nil, handshake?: true, owner_pid: #PID<0.711.0>, socket: #Port<0.46>, ssl_opts: [active: false, cb_info: {Tds.Tls, :tcp, :tcp_closed, :tcp_error}]}

After short investigation I found out that build in Docker used OTP 25 while on my local machine I was still using OTP 24 and installing Elixir 1.13.4-otp-25 resulted in the same error.

I was not able to find any issue related to this reported on Tds so I wonder if anyone have noticed similar problem or has an idea what could cause this error?

Showing Posts 1 to 4

moogle19

moogle19

Hi @bosko
I just pushed a small fix for your problem to the master branch.
Could you try it? Just switch your dep in mix.exs to {:tds, github: "elixir-ecto/tds"}.

If you have problems in the future, just open up an issue on the GitHub repo. It will be more visible there.

bosko

bosko OP

Hi @moogle19,

Thanks for the quick reply. I was not sure if it was Tds or OTP 25 problem so I didin’t want to unnecessary pollute issues.

I’ve just tried version from Git but, unfortunately, it still does not work but now error is different:

[error] Tds.Protocol (#PID<0.621.0>) failed to connect: ** (Tds.Error) Unable to establish secure connection to server due :closed
[error] GenServer #PID<0.637.0> terminating                                                                       
** (stop) :tcp_closed                                                                                             
Last message: {:tcp_closed, #Port<0.22>}
State: %Tds.Tls{buffer: nil, handshake?: true, owner_pid: #PID<0.664.0>, socket: #Port<0.22>, ssl_opts: [active: false, cb_info: {Tds.Tls, :tcp, :tcp_closed, :tcp_error}]}
[warning] Description: 'Authenticity is not established by certificate path validation'
     Reason: 'Option {verify, verify_peer} and cacertfile/cacerts is missing'
                                                                                                                  
[error] GenServer #PID<0.629.0> terminating                                                                       
** (stop) :tcp_closed
Last message: {:tcp_closed, #Port<0.27>}                                                                          
State: %Tds.Tls{buffer: nil, handshake?: true, owner_pid: #PID<0.661.0>, socket: #Port<0.27>, ssl_opts: [active: false, cb_info: {Tds.Tls, :tcp, :tcp_closed, :tcp_error}]}
[error] GenServer #PID<0.636.0> terminating
** (stop) :tcp_closed                                                                                             
Last message: {:tcp_closed, #Port<0.25>}                                                                          
State: %Tds.Tls{buffer: nil, handshake?: true, owner_pid: #PID<0.659.0>, socket: #Port<0.25>, ssl_opts: [active: false, cb_info: {Tds.Tls, :tcp, :tcp_closed, :tcp_error}]}
[error] Tds.Protocol (#PID<0.617.0>) failed to connect: ** (Tds.Error) Unable to establish secure connection to server due :closed
[error] Tds.Protocol (#PID<0.624.0>) failed to connect: ** (Tds.Error) Unable to establish secure connection to server due :closed
[error] GenServer #PID<0.628.0> terminating
** (stop) :tcp_closed                                                                                             
Last message: {:tcp_closed, #Port<0.20>}                                                                          
State: %Tds.Tls{buffer: nil, handshake?: true, owner_pid: #PID<0.665.0>, socket: #Port<0.20>, ssl_opts: [active: false, cb_info: {Tds.Tls, :tcp, :tcp_closed, :tcp_error}]}
[error] Tds.Protocol (#PID<0.618.0>) failed to connect: ** (Tds.Error) Unable to establish secure connection to server due :closed
moogle19

moogle19

Hmm, it seems the TCP connection gets closed before the SSL handshake succeeds.
Could you share your config? Have you set some custom ssl_opts in your config?

I have created an issue for further discussion (so we don’t spam the forum :smile:): TLS connection error with OTP 25 · Issue #136 · elixir-ecto/tds · GitHub

gregvaughn

gregvaughn

We had to abort an upgrade to OTP 25 because of failures negotiating a TLS connection with a Windows server. That might be the same root cause here. Looks like a fix has been merged for OTP now
https://github.com/erlang/otp/pull/6037

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews