Qt6 QSslSocket 客户端设计踩坑

QSslSocket 默认自动搜索代理设置,当系统中存在代理时,执行 connectToHostEncrypted 会导致 socket error: UnsupportedSocketOperationError,具体错误是 connect error is  "The proxy type is invalid for this operation";

查找原因步骤:(执行以下代码,可以获取具体失败原因)

  this->connectToHostEncrypted(qstrIP, port);
  bool b = this->waitForEncrypted();
  if (!b) {
    qDebug() << "connect error is " << this->errorString();
  }

解决办法:

先:this->setProxy(QNetworkProxy::NoProxy);

后:this->connectToHostEncrypted(qstrIP, port);

相关推荐

  1. Qt6 QSslSocket 客户设计

    2024-06-05 19:48:13       32 阅读
  2. Qt建立服务客户

    2024-06-05 19:48:13       36 阅读
  3. iOS和安卓个人

    2024-06-05 19:48:13       57 阅读
  4. Qt Creator 项目Console 项目日记

    2024-06-05 19:48:13       26 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-05 19:48:13       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-05 19:48:13       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-05 19:48:13       87 阅读
  4. Python语言-面向对象

    2024-06-05 19:48:13       96 阅读

热门阅读

  1. 里氏替换原则经典反例:正方形不是长方形

    2024-06-05 19:48:13       34 阅读
  2. Spring Cloud Gateway通过配置文件方式提供路由服务

    2024-06-05 19:48:13       29 阅读
  3. 竹纤维家装元宇宙:虚拟空间与绿色生活的融合

    2024-06-05 19:48:13       33 阅读
  4. 生活中的人工智能

    2024-06-05 19:48:13       32 阅读
  5. SVN在Linux服务器下部署过程

    2024-06-05 19:48:13       31 阅读
  6. 如何评价GPT-4o?

    2024-06-05 19:48:13       32 阅读
  7. Python for的用法:深入解析与实战应用

    2024-06-05 19:48:13       33 阅读