Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
MQTTnet
提交
36736914
MQTTnet
项目概览
dotNET Platform
/
MQTTnet
10 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MQTTnet
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
36736914
编写于
10月 23, 2022
作者:
C
Christian
提交者:
GitHub
10月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Xamarin connect freeze (#1545)
上级
7823d834
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
23 addition
and
3 deletion
+23
-3
.github/workflows/ReleaseNotes.md
.github/workflows/ReleaseNotes.md
+1
-0
Source/MQTTnet.Tests/Client/MqttClient_Tests.cs
Source/MQTTnet.Tests/Client/MqttClient_Tests.cs
+1
-1
Source/MQTTnet/Adapter/MqttChannelAdapter.cs
Source/MQTTnet/Adapter/MqttChannelAdapter.cs
+21
-2
未找到文件。
.github/workflows/ReleaseNotes.md
浏览文件 @
36736914
*
[Client] Fixed connection freeze when using Xamarin etc.
\ No newline at end of file
Source/MQTTnet.Tests/Client/MqttClient_Tests.cs
浏览文件 @
36736914
...
...
@@ -123,7 +123,7 @@ namespace MQTTnet.Tests.Client
//Assert.IsInstanceOfType(exception.InnerException, typeof(SocketException));
}
await
Task
.
Delay
(
100
);
// disconnected handler is called async
await
LongTestDelay
(
);
// disconnected handler is called async
Assert
.
IsTrue
(
disconnectHandlerCalled
);
}
}
...
...
Source/MQTTnet/Adapter/MqttChannelAdapter.cs
浏览文件 @
36736914
...
...
@@ -23,7 +23,7 @@ namespace MQTTnet.Adapter
{
const
uint
ErrorOperationAborted
=
0x800703E3
;
const
int
ReadBufferSize
=
4096
;
readonly
IMqttChannel
_channel
;
readonly
byte
[]
_fixedHeaderBuffer
=
new
byte
[
2
];
readonly
MqttNetSourceLogger
_logger
;
...
...
@@ -73,7 +73,26 @@ namespace MQTTnet.Adapter
try
{
await
_channel
.
ConnectAsync
(
cancellationToken
).
ConfigureAwait
(
false
);
/*
* We have to implement a small workaround here to support connecting in Xamarin
* with a disabled WiFi network. If the WiFi is disabled the connect method will
* block forever. Even a cancellation token is not supported properly.
*/
var
connectTask
=
_channel
.
ConnectAsync
(
cancellationToken
);
var
timeout
=
new
TaskCompletionSource
<
object
>();
using
(
cancellationToken
.
Register
(()
=>
timeout
.
TrySetResult
(
null
)))
{
await
Task
.
WhenAny
(
connectTask
,
timeout
.
Task
).
ConfigureAwait
(
false
);
if
(
timeout
.
Task
.
IsCompleted
&&
!
connectTask
.
IsCompleted
)
{
throw
new
OperationCanceledException
(
"MQTT connect cancelled."
,
cancellationToken
);
}
// Make sure that the exception from the connect task gets thrown.
await
connectTask
.
ConfigureAwait
(
false
);
}
}
catch
(
Exception
exception
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录