gpt4 book ai didi

c++ - 从 Qt 5.7 切换到 Qt 5.8 - "the proxy type is invalid for this operation"

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:10:40 33 4
gpt4 key购买 nike

我正在尝试使用 Qt 5.8 重新编译一个在 Qt 5.7 上运行良好的网络应用程序。但是,使用 Qt 5.8,服务器无法listen():

int myPort = 52000; //some accessible port
QTcpServer* server = new QTcpServer();
if(!server->listen(QHostAddress::Any, myPort))
{
qDebug() << server.errorString();
}

返回的错误是:

The proxy type is invalid for this operation

我确实在受代理保护的公司网络上运行该应用程序,但是在以前的 Qt 版本中,从来不需要进行任何类型的设置来解决这个问题。我以前从未见过 listen() 命令失败。

有什么想法在 Qt 5.8 中有什么变化或如何解决这个问题吗?

编辑:

当整个网络被代理时,本地域上的通信不需要代理,NO_PROXY 环境变量被设置为避免代理本地连接。

最佳答案

在 Qt 5.8 中,默认使用系统代理设置,但似乎不遵守 NO_PROXY 设置。

在创建 QTcpServer 实例之前设置 QNetworkProxyFactory::useSystemConfiguration(false); 修复了错误(基本上通过恢复 Qt 5.7 默认值)。

关于c++ - 从 Qt 5.7 切换到 Qt 5.8 - "the proxy type is invalid for this operation",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42121008/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com