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

Unable to Establish HTTPS Connection on Non-Tuya Server Using TuyaOS SDK #10

Open
espark-maaz opened this issue Jun 25, 2024 · 0 comments

Comments

@espark-maaz
Copy link

Issue Title:

Unable to Establish HTTPS Connection on Non-Tuya Server Using TuyaOS SDK

Issue Description:

I'm encountering difficulties establishing an HTTPS connection to a non-Tuya server using the TuyaOS SDK. Below are the relevant logs from my application:

[01-01 00:00:04 ty D][lr:0x8146d] cache dns [REDACTED_URL]<->[REDACTED_IP]
[01-01 00:00:04 ty D][lr:0x9c779] DNS parse type:2
[01-01 00:00:04 ty D][lr:0x9c82f] bind port:0 ok
[01-01 00:00:05 ty E][lr:0x5b511] MAX SECURITY_LEVEL CONFIG ERROR: L->0,M->1
[01-01 00:00:05 ty E][lr:0x84847] tls transporter connect err:-2
[01-01 00:00:05 ty D][lr:0x84715] tls transporter close socket fd:1
[01-01 00:00:05 ty D][lr:0x9c8f5] tcp transporter close socket fd:1
[01-01 00:00:05 ty D][lr:0x8472f] tls transporter close tls handler:0x4252bc
[01-01 00:00:05 ty D][lr:0x5b827] TUYA_TLS Disconnect ENTER
[01-01 00:00:05 ty D][lr:0x5b877] TUYA_TLS Disconnect Success
[01-01 00:00:05 ty D][lr:0x76d99] Connect: [REDACTED_URL] Port: 7000 --<< ,r:-1
[01-01 00:00:05 ty D][lr:0x92cd1] Get Rssi:-63
[01-01 00:00:05 ty D][lr:0x8d8e3] url:[REDACTED_URL]
[01-01 00:00:05 ty D][lr:0x8d8f7] pstr:.[REDACTED_DOMAIN]
[01-01 00:00:05 ty D][lr:0x84715] tls transporter close socket fd:-1
[01-01 00:00:05 ty D][lr:0x84741] tls transporter already closed
[01-01 00:00:05 ty D][lr:0x5b4b3] tuya_tls_connect_destroy.
[01-01 00:00:05 ty D][lr:0x81559] lower_dns_cache_priority:0
[01-01 00:00:05 ty E][custom_http_client.c:321] Error opening HTTP session.(code: -1)

Steps to Reproduce:

  1. Attempt to establish an HTTPS connection to a non-Tuya server using the TuyaOS SDK.
  2. Observe the logs provided above.

Expected Behavior:

The HTTPS connection should be successfully established without errors.

Actual Behavior:

The connection attempt fails with the following error: Error opening HTTP session.(code: -1).

Environment Details:

  • TuyaOS SDK version: [3.9.0]
  • Device/Platform: [Beken7231n]
  • Server URL: [REDACTED_URL]

Additional Information:

  • I have confirmed that the server is reachable and operational as I have tested with python server.
  • I have verified the correctness of the server URL.
tuya_tls_config_t tls_config;
tls_config.mode = TUYA_TLS_SERVER_CERT_MODE;  // Example mode, adjust as needed
tls_config.hostname = host_uri;
tls_config.port = 7000;  // HTTPS port

// Set CA certificate (assuming CA_CERT is defined as per your previous definitions)
tls_config.ca_cert = CA_CERT;
tls_config.ca_cert_size = strlen(CA_CERT);

// Set timeout and other parameters as needed
tls_config.timeout = 10;  // Example timeout

// If you have client certificate and key, set them as follows:
tls_config.client_pkey = SSL_PRIVATE_KEY;
tls_config.client_pkey_size = strlen(SSL_PRIVATE_KEY);

/* Setup callbacks */
tls_config.f_send = send_callback;
tls_config.f_recv = recv_callback;
tls_config.exception_cb = event_callback;

// Open HTTP session with Tuya TLS configuration
int http_ret = http_open_session_with_config(&https_handle, host_uri, &tls_config, TLS_ENABLE, 0);

Proposed Solution:

Please investigate the logs provided and advise on any configuration changes or updates to the TuyaOS SDK that may be required to establish HTTPS connections to non-Tuya servers successfully and also explain what error this line is referring to specifically L->0 and M->0:

[01-01 00:00:05 ty E][lr:0x5b511] MAX SECURITY_LEVEL CONFIG ERROR: L->0,M->1
[01-01 00:00:05 ty E][lr:0x84847] tls transporter connect err:-2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant