-
Notifications
You must be signed in to change notification settings - Fork 38
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
Unable to connect to clickhouse through HAProxy #80
Comments
@wezell thank you for detailed report. I'll check. |
@wezell okey, I did some tests and all seems to be working. At least direct ssl connection without proxy. Do you use self generated certificates?
|
setSsl set to true and the cert is not self signed. It is a legit cert. sslType is none anyway. Without the proxy, clickhouse4j can connect without ssl. Keep in mind that curl connects to https and queries fine. |
Does ssl connection work without proxy?
I understand, I trying to narrow down the problem. Here a test I used:
|
Dmitriy - To remove variables, I took out the SSL and it is reproducible through just HAProxy. The yandex jdbc driver works fine: import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
/*
import cc.blynk.clickhouse.ClickHouseDataSource;
import cc.blynk.clickhouse.settings.ClickHouseProperties;
*/
import ru.yandex.clickhouse.ClickHouseDataSource;
import ru.yandex.clickhouse.settings.ClickHouseProperties;
public class ClickHouse4JTest {
@Test
public void testUpdateCountForSelect() throws SQLException {
ClickHouseProperties properties = new ClickHouseProperties();
properties.setSsl(false);
ClickHouseDataSource dataSource = new ClickHouseDataSource(
"jdbc:clickhouse://realhost.com:8080?password=xxxxxx&user=default", properties);
try (Connection connection = dataSource.getConnection()) {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT dummy FROM system.one");
assertEquals(stmt.getUpdateCount(), -1);
rs.next();
assertEquals(stmt.getUpdateCount(), -1);
rs.close();
stmt.close();
}
}
} but clickhouse4j does not import static org.junit.Assert.assertEquals;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.junit.Test;
import cc.blynk.clickhouse.ClickHouseDataSource;
import cc.blynk.clickhouse.settings.ClickHouseProperties;
/*
import ru.yandex.clickhouse.ClickHouseDataSource;
import ru.yandex.clickhouse.settings.ClickHouseProperties;
*/
public class ClickHouse4JTest {
@Test
public void testUpdateCountForSelect() throws SQLException {
ClickHouseProperties properties = new ClickHouseProperties();
properties.setSsl(false);
ClickHouseDataSource dataSource = new ClickHouseDataSource(
"jdbc:clickhouse://realhost.com:8080?password=xxxxxx&user=default", properties);
try (Connection connection = dataSource.getConnection()) {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT dummy FROM system.one");
assertEquals(stmt.getUpdateCount(), -1);
rs.next();
assertEquals(stmt.getUpdateCount(), -1);
rs.close();
stmt.close();
}
}
} Truly, HAProxy's config could not be more simple. Nothing exotic at all. My guess is that haproxy doesn't like the http handshake or request - maybe an missing/extra line break, an missing/unexpected header something like that. Here is my HAProxy config.
|
Thanks. Now it is clear where to dig. |
@doom369 I am facing the same issue, can you help me out? |
I have a clickhouse instance running behind haproxy, which is doing SSL termination. I can connect to clickhouse and run queries using curl, it just won't work with clickhouse4j. To test, I used dBeaver and I can also connect to HTTPS using dBeaver and the official clickhouse driver and this works. But if I try to connect using clickhouse4j - same connection settings, just different driver, I get a
Your browser sent an invalid request.
message. This is the same result I am seeing in my java code. Note that my SSL cert is valid and there are no server name / ssl type issues.curl http works
curl https works
dBeaver + official driver https works
I can connect to HTTPS using dBeaver and the official clickhouse driver:
dBeaver + clickhouse4j driver does not work
The text was updated successfully, but these errors were encountered: