Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom MySQL port for BW unified #2516

Closed
1 task done
Tracked by #2480
rusty1281 opened this issue Dec 25, 2022 · 6 comments · Fixed by #2520
Closed
1 task done
Tracked by #2480

Custom MySQL port for BW unified #2516

rusty1281 opened this issue Dec 25, 2022 · 6 comments · Fixed by #2520
Labels
bug bw-unified-deploy An Issue related to Bitwarden unified deployment help wanted

Comments

@rusty1281
Copy link

Steps To Reproduce

Hello,

was wondering if there is any way to run BW unified against an external DB running on a custom port? the BW_DB_SERVER when populated with an IP address and no port does not work, as well as with an added port in this format IP:port

Expected Result

Connect BW to an external DB with custom port

Actual Result

No DB connection/initial table creation

Screenshots or Videos

fail: Bit.Admin.Jobs.DatabaseExpiredGrantsJob[2]
Error performing DeleteSendsJob.
MySqlConnector.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.

Additional Context

No response

Githash Version

455d62e-dirty

Environment Details

Docket 20.10.3

Database Image

MySQL 8

Issue-Link

#2480

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@rusty1281 rusty1281 added bug bw-unified-deploy An Issue related to Bitwarden unified deployment labels Dec 25, 2022
@rusty1281
Copy link
Author

Just wanted to add that using the BW_DB_PROVIDER=sqlite and BW_DB_FILE=/etc/bitwarden/vault.db as part of the stack, also results in an error:

fail: Bit.Admin.HostedServices.DatabaseMigrationHostedService[0]
      Database unavailable for migration. Trying again (attempt #2)...
      System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)

@justindbaur
Copy link
Member

justindbaur commented Dec 27, 2022

Just wanted to add that using the BW_DB_PROVIDER=sqlite and BW_DB_FILE=/etc/bitwarden/vault.db as part of the stack, also results in an error:

@rusty1281 Are you on the beta tag? I believe SQLite support is only on the dev tag right now and so it's falling back to SQL Server because it can't handle sqlite and that's why it's throwing a SqlException.

@rusty1281
Copy link
Author

Tnx for the reply. Yes I am on beta and have not tried the DEV tag.

So the question is can I use beta tag with external SQL on a custom port?

@justindbaur
Copy link
Member

It should be able to but I won't have a chance to recreate it myself until the end of the week. @kspearrin any thoughts? We were using docker compose to orchestrate this setup and if so can you post it all redacting any sort of passwords so I can recreate it more closely?

@kspearrin
Copy link
Member

Here is how we construct connection strings today:

MYSQL_CONNECTION_STRING="server=$BW_DB_SERVER;database=$BW_DB_DATABASE;user=$BW_DB_USERNAME;password=$BW_DB_PASSWORD"
POSTGRESQL_CONNECTION_STRING="Host=$BW_DB_SERVER;Database=$BW_DB_DATABASE;Username=$BW_DB_USERNAME;Password=$BW_DB_PASSWORD"
SQLSERVER_CONNECTION_STRING="Server=$BW_DB_SERVER;Database=$BW_DB_DATABASE;User Id=$BW_DB_USERNAME;Password=$BW_DB_PASSWORD;"
SQLITE_CONNECTION_STRING="Data Source=$BW_DB_FILE;"

According to here, we need to add ;port= to the connection string builder to support non-default ports. I will work on a PR for that.

@rusty1281 For now, you can just specify your own full connection string rather than using the BW_DB_* options. Just add this env variable and it will take precedence.

globalSettings__mysql__connectionString=server=db_server;port=1234;database=db_name;user=db_user;password=db_password

@rusty1281
Copy link
Author

@rusty1281 For now, you can just specify your own full connection string rather than using the BW_DB_* options. Just add this env variable and it will take precedence.

Thank you @kspearrin for this info. It works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bw-unified-deploy An Issue related to Bitwarden unified deployment help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants