Comments (11)
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.
It was occasionally closed.
from mariaex.
Thanks @jquadrin and @liveforeverx !
from mariaex.
If nobody working on errors at the moment, I'll tackle this.
from mariaex.
@liveforeverx I just changed the message, feel free to close if you are working on it already
from mariaex.
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.
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.
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.
Beautiful!
José Valimwww.plataformatec.com.br
http://www.plataformatec.com.br/Founder and Lead Developer
from mariaex.
I think, the issue can be closed for a long time.
from mariaex.
from mariaex.
Related Issues (20)
- ping_handle does not handle errors HOT 1
- Deploy 0.9.0 into hex.pm HOT 2
- mariaex error HOT 8
- leaks connections HOT 9
- Inserting large polygons HOT 1
- FunctionClauseError when connecting to a mysql db on azure
- Geometry is master branch but not released to Hex.pm HOT 1
- error when using cache_size = 1
- connections not closed properly? HOT 1
- Can't create more than max_prepared_stmt_count statements (current value: 16382) HOT 2
- Deprecation messages with Erlang/OTP 20 - Elixir 1.5.3
- Finish migration to DBConnection 2.0
- handle_handshake exceptions out on odd username circumstances
- version 0.8.5 not released HOT 4
- ssl recv timeout on mysql/percona 5.7 connection with TLS enabled HOT 3
- Connections not properly closed on errors HOT 8
- Invalid utf-8 byte sequences in varchar HOT 4
- Issue with inserting points HOT 1
- FunctionClauseError in Messages.decode_msg/2
- Time data type support for full range
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mariaex.