azure-iot-hub - iOS 14 无法识别的选择器发送到 IoTHubClient_LL_DoWork() 上的实例异常
问题描述
更新到 iOS 14 后,只要遇到IoTHubClient_LL_DoWork()
代码,就会导致一致的崩溃。
日志:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x7fff801abf28'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff20438fda __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff2017712e objc_exception_throw + 48
2 CoreFoundation 0x00007fff20447b29 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 CoreFoundation 0x00007fff2043d510 forwarding + 1479
4 CoreFoundation 0x00007fff2043f548 _CF_forwarding_prep_0 + 120
5 CFNetwork 0x00007fff235bfa29 _CFStreamErrorFromCFError + 216339
6 CFNetwork 0x00007fff235b67cd _CFStreamErrorFromCFError + 178871
7 CoreFoundation 0x00007fff203c88bf CFReadStreamSetProperty + 93
8 AzureIoTUtility 0x000000010da5a848 dowork_poll_socket + 136
9 AzureIoTUtility 0x000000010da5a183 tlsio_appleios_dowork + 179
10 AzureIoTUtility 0x000000010da66f04 xio_dowork + 52
11 AzureIoTuMqtt 0x000000010db1f0c3 mqtt_client_dowork + 115
12 AzureIoTHubClient 0x000000010d99de7e IoTHubTransport_MQTT_Common_DoWork + 1038
13 AzureIoTHubClient 0x000000010d9ae905 IoTHubTransportMqtt_DoWork + 21
14 AzureIoTHubClient 0x000000010d96e581 IoTHubClientCore_LL_DoWork + 337
15 AzureIoTHubClient 0x000000010d972da5 IoTHubClient_LL_DoWork + 21
16 Locate2u 0x000000010cf58b31 $s8Locate2u22ServerMessagingServiceC6doworkyyF + 33
17 Locate2u 0x000000010cf58b6b $s8Locate2u22ServerMessagingServiceC6doworkyyFTo + 43
18 Foundation 0x00007fff2086e90c __NSFireTimer + 67
19 CoreFoundation 0x00007fff203a7ed4 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
20 CoreFoundation 0x00007fff203a79a7 __CFRunLoopDoTimer + 926
21 CoreFoundation 0x00007fff203a6f5a __CFRunLoopDoTimers + 265
22 CoreFoundation 0x00007fff203a15e8 __CFRunLoopRun + 1949
23 CoreFoundation 0x00007fff203a0960 CFRunLoopRunSpecific + 567
24 GraphicsServices 0x00007fff2b9e7db3 GSEventRunModal + 139
25 UIKitCore 0x00007fff245f5bd9 -[UIApplication _run] + 912
26 UIKitCore 0x00007fff245faaea UIApplicationMain + 101
27 Locate2u 0x000000010cf7f21b main + 75
28 libdyld.dylib 0x00007fff20256431 start + 1
29 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x7fff801abf28'
terminating with uncaught exception of type NSException
CoreSimulator 732.10 - Device: iPhone 11 Pro 14 (81C14598-2ABC-4BF2-9064-51EF9C9A31B0) - Runtime: iOS 14.0 (18A5342e) - DeviceType: iPhone 11 Pro
This process is running with libgmalloc.dylib (GuardMalloc) which may have forced the crash due to a memory access error.
解决方案
在此处添加答案以供来自 Git 问题的参考链接:
它需要一本字典。替换以下代码
static void dowork_poll_socket(TLS_IO_INSTANCE* tls_io_instance)
{
// This will pretty much only fail if we run out of memory
CFStreamCreatePairWithSocketToHost(NULL, tls_io_instance->hostname, tls_io_instance->port, &tls_io_instance->sockRead, &tls_io_instance->sockWrite);
if (tls_io_instance->sockRead != NULL && tls_io_instance->sockWrite != NULL)
{
// Micha Edits
CFStringRef keys[1] = {kCFStreamPropertySocketSecurityLevel};
CFStringRef values[1] = {kCFStreamSocketSecurityLevelNegotiatedSSL};
CFDictionaryRef test = CFDictionaryCreate(NULL , (void *)keys , (void *)values , 1, NULL , NULL);
if (CFReadStreamSetProperty(tls_io_instance->sockRead, kCFStreamPropertySSLSettings, test))
//if (CFReadStreamSetProperty(tls_io_instance->sockRead, kCFStreamPropertySSLSettings, kCFStreamSocketSecurityLevelNegotiatedSSL))
{
tls_io_instance->tlsio_state = TLSIO_STATE_OPENING_WAITING_SSL;
}
else
{
LogError("Failed to set socket properties");
enter_open_error_state(tls_io_instance);
}
CFRelease(test);
}
else
{
LogError("Unable to create socket pair");
enter_open_error_state(tls_io_instance);
}
}
此外,IoTHubClient 的最新 CocoaPod 是:pod 'AzureIoTHubClient', '=1.3.9-LTS'。cocoapods 网站可能没有直接指向它,尽管它比较新。每当我们发布新的 Pod 时,您都可以在这个 Podfile 中找到最新的引用。
推荐阅读
- python - 在 Eclipse FileNotFoundError 上设置 Selenium 和 Python:[WinError 2]
- sql - 我如何才能对在 SQL 中保存为 nvarchar 的日期进行排序
- css - 使用媒体查询的 Bootstrap 列顺序有问题
- javascript - 为什么手动计算字符串中的字符索引返回-1?
- r - 标记组的第一个(或第 n 个)观察
- css - AndroidSVG:如何动态更改 Inkscape svg 颜色
- oracle - 使用 Spring 4.3.0 JDBC 模板插入或更新逻辑的总记录的 5% 的处理时间很长
- javascript - 如何使用 Jasmine 监视多个类/对象方法
- python - 我正在尝试使用 notepad++ 启动一个简单的计算器程序,我做错了什么?
- javascript - 无法使用 React 实现侧导航栏