GithubHelp home page GithubHelp logo

Comments (11)

josevalim avatar josevalim commented on July 18, 2024

Can we please reopen this one? All we are going to say in this case is that the tcp connection is closed, which is an improvement, but I would rather say we can't authenticate in the first place. Otherwise users will be clueless to why the connection was closed. :)

from mariaex.

liveforeverx avatar liveforeverx commented on July 18, 2024

It was occasionally closed.

from mariaex.

josevalim avatar josevalim commented on July 18, 2024

Thanks @jquadrin and @liveforeverx !

from mariaex.

liveforeverx avatar liveforeverx commented on July 18, 2024

If nobody working on errors at the moment, I'll tackle this.

from mariaex.

jquadrino avatar jquadrino commented on July 18, 2024

@liveforeverx I just changed the message, feel free to close if you are working on it already

from mariaex.

josevalim avatar josevalim commented on July 18, 2024

The current message is fine. TCP can be closed in other situations. We just need to explicitly check those for authentication errors. I think postgrex even has specific tests for this kind of stuff. :)

from mariaex.

liveforeverx avatar liveforeverx commented on July 18, 2024

So, pushed to master the code, that tests false user/database and shows error. Next step to test the connection with password/false password, will do it somewhere tomorrow.

Tried to find the test on postgrex, but didn't find, where it tested... @josevalim , see this line: https://github.com/liveforeverx/mariaex/blob/master/lib/mariaex/connection.ex#L64 (avoiding of a problem), sometimes it happens, that tcp_closed will got and process terminated(with the linked starter process), before starter process get error. This lead to undefined behaviour, if trap_exit set to false:

iex(1)> Mariaex.Connection.start_link(database: "non_existing")
** (EXIT from #PID<0.104.0>) %Mariaex.Error{mariadb: nil, message: "connection closed"}

Interactive Elixir (1.1.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)>
22:52:39.904 [error] GenServer #PID<0.106.0> terminating
Last message: {:tcp_closed, #Port<0.15965>}
State: %{backend_key: nil, opts: [hostname: "localhost", password: nil, username: "dima", database: "non_existing"], parameters: %{}, queue: {[], []}, rows: [], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.15965>}, sock_mod: Mariaex.Connection.Tcp, state: :running, statement: nil, tail: "", types: :types_removed}
** (exit) %Mariaex.Error{mariadb: nil, message: "connection closed"}
iex(1)> Mariaex.Connection.start_link(database: "non_existing")
{:error,
 %Mariaex.Error{mariadb: %{code: 1044,
    message: "Access denied for user ''@'localhost' to database 'non_existing'"},
  message: "Access denied for user ''@'localhost' to database 'non_existing'"}}

Do not tested it on postgrex, but it can have the same problem.

from mariaex.

liveforeverx avatar liveforeverx commented on July 18, 2024

So, tested with master(fix password authorization):

iex> Mariaex.Connection.start_link(username: "pass", password: "wrong_pass", database: "ecto_test")
{:error,
 %Mariaex.Error{mariadb: %{code: 1045,
    message: "Access denied for user 'pass'@'localhost' (using password: YES)"},
  message: nil}}

iex> Mariaex.Connection.start_link(username: "pass", password: "pass", database: "ecto_test")
{:ok, #PID<0.106.0>}

And, there are tests for all other cases(false user | database, impossible to connect to database(tcp error)) here: https://github.com/liveforeverx/mariaex/blob/master/test/start_test.exs

from mariaex.

josevalim avatar josevalim commented on July 18, 2024

Beautiful!

José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Lead Developer

from mariaex.

liveforeverx avatar liveforeverx commented on July 18, 2024

I think, the issue can be closed for a long time.

from mariaex.

josevalim avatar josevalim commented on July 18, 2024

❤️ 💚 💙 💛 💜

from mariaex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.