Skip to content

"The plain HTTP request was sent to HTTPS port" error in release 0.334 #557

Closed
@radoslav-dimitrov-indeavr

Description

Expected behavior

Hi, all.

Upon upgrading to version 0.334.0 we started receiving the following error message when connecting via Trino using Python and SQLAlchemy:

HttpError("error 400: b'<html>\\r\\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\\r\\n<body>\\r\\n<center><h1>400 Bad Request</h1></center>\\r\\n<center>The plain HTTP request was sent to HTTPS port</center>\\r\\n</body>\\r\\n</html>\\r\\n'")

We tested that the issue does not exist in versions 0.329 or 0.333.

I cannot find any info on how to use HTTPS requests other than by setting the port to 443.

Expected behaviour: connect to Trino as before.

PS: why doesn't this template have a "Summary" tab?

Actual behavior

A connection attempt to Trino via Python and SQLAlchemy trigger the error message noted above. Reproducing here:

HttpError("error 400: b'<html>\\r\\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\\r\\n<body>\\r\\n<center><h1>400 Bad Request</h1></center>\\r\\n<center>The plain HTTP request was sent to HTTPS port</center>\\r\\n</body>\\r\\n</html>\\r\\n'")

Steps To Reproduce

Steps:

  1. Import Trino's URL function
  2. Create a Trino URL with host, port, user, password and catalog fields
  3. Create an SQLAlchemy engine
  4. Run a query

Code:

from sqlalchemy import create_engine, text
from trino.sqlalchemy import URL as URL_trino
 
url = URL_trino(
    host="server",
    port=443,
    user="username",
    password="password",
    catalog="catalog",
)
engine = create_engine(url)
 
with engine.connect() as con:
    result = con.execute(text("select version()")).scalar()
    print(result)

Log output

Here is a traceback:

Traceback (most recent call last):
  File "C:\Users\rdimitrov\test.py", line 14, in <module>
    result = con.execute(text("select version()")).scalar()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1416, in execute
    return meth(
           ^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\sql\elements.py", line 523, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1638, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1843, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1983, in _exec_single_context
    self._handle_dbapi_exception(
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 2355, in _handle_dbapi_exception
    raise exc_info[1].with_traceback(exc_info[2])
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\sqlalchemy\engine\base.py", line 1964, in _exec_single_context
    self.dialect.do_execute(
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\trino\sqlalchemy\dialect.py", line 442, in do_execute
    cursor.execute(statement, parameters)
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\trino\dbapi.py", line 629, in execute
    self._iterator = iter(self._query.execute())
                          ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\trino\client.py", line 886, in execute
    status = self._request.process(response)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\trino\client.py", line 684, in process
    self.raise_response_error(http_response)
  File "C:\Users\rdimitrov\AppData\Local\Programs\Python\Python312\Lib\site-packages\trino\client.py", line 675, in raise_response_error
    raise exceptions.HttpError(
trino.exceptions.HttpError: error 400: b'<html>\r\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<center>The plain HTTP request was sent to HTTPS port</center>\r\n</body>\r\n</html>\r\n'

Operating System

Windows 10 Enterprise 22H2 OS Build: 19045.5737

Trino Python client version

0.334.0

Trino Server version

443-e.6

Python version

3.12.4

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions