1. 我搜索了之前的帖子,发现有一位老哥提出过类似问题,并且有工作人员回复说,是因为 LiveQuery 的实例被释放了。
  2. 于是我将 LiveQuery 的实例做成了一个单例
  3. 我在LeancCloud 控制台对 TeamRoom 表进行编辑。
  4. 我写了一个 nodejs 的 demo,nodejs 的 demo 是**可以**收到 update 的 event 事件的。
  5. SwiftUI 无法收到事件

希望得到你们的帮助。谢谢!

代码如下:
LiveQuery 单例:

调用LiveQuery 的页面:

请问使用的 SDK 的版本号是什么?能否提供 SDK 的相关日志?

使用的版本是 LeanCloud (17.8.0)
日志如下:

2021-06-21 18:11:42.699700+0800 Yanxishe[68543:3531203] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "dev-api.suoxue.today";
    srvr = "dev-api.suoxue.today";
    sync = syna;
}
[💙][debug][LeanCloud][2021-06-21 18:11:42.700][HTTPClient.swift][#410][lcDebugDescription()]: 
------ BEGIN LeanCloud HTTP Request
task: 3
curl: curl -v \
	-X GET \
	-H "X-LC-Session: 2uqopooxtc2b57hptq3kiu2ua" \
	-H "X-LC-Sign: bd72c331efdbde75f54482446251cecb,1624270302698" \
	-H "X-LC-Id: A2NVO31pitasJoNEmaIIMPTn-gzGzoHsz" \
	-H "X-LC-Prod: 1" \
	-H "User-Agent: LeanCloud-Swift-SDK/17.8.0" \
	-H "Accept: application/json" \
	"https://dev-api.suoxue.today/1.1/classes/TeamRoom?className=TeamRoom&where=%7B%22%24and%22%3A%5B%7B%22team%22%3A%7B%22className%22%3A%22LCObject%22%2C%22__type%22%3A%22Pointer%22%2C%22objectId%22%3A%2260cdb94d8f119d3e259d05d1%22%7D%7D%5D%7D"
------ END
[💛][verbose][LeanCloud][2021-06-21 18:11:42.703][RTMConnection.swift][#529][init(application:lcimProtocol:)]: 
RTMConnection: 8899c485f9344702b1103c059ef7d6dc
    - application state: foreground
[💛][verbose][LeanCloud][2021-06-21 18:11:42.704][RTMConnection.swift][#748][networkReachabilityStatusChanged(with:)]: 
RTMConnection: 8899c485f9344702b1103c059ef7d6dc
    - network reachability status: reachable(Alamofire.NetworkReachabilityManager.NetworkReachabilityStatus.ConnectionType.ethernetOrWiFi)
2021-06-21 18:11:42.707912+0800 Yanxishe[68543:3531203] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "dev-api.suoxue.today";
    srvr = "dev-api.suoxue.today";
    sync = syna;
}
[💙][debug][LeanCloud][2021-06-21 18:11:42.708][HTTPClient.swift][#410][lcDebugDescription()]: 
------ BEGIN LeanCloud HTTP Request
task: 4
curl: curl -v \
	-X GET \
	-H "Accept: application/json" \
	-H "X-LC-Sign: a5b2cbc24a179ace8d50911ed5955bee,1624270302706" \
	-H "X-LC-Prod: 1" \
	-H "X-LC-Id: A2NVO31pitasJoNEmaIIMPTn-gzGzoHsz" \
	-H "User-Agent: LeanCloud-Swift-SDK/17.8.0" \
	-H "X-LC-Session: 2uqopooxtc2b57hptq3kiu2ua" \
	"https://dev-api.suoxue.today/v1/route?appId=A2NVO31pitasJoNEmaIIMPTn-gzGzoHsz&secure=1"
------ END
[💙][debug][LeanCloud][2021-06-21 18:11:42.746][HTTPClient.swift][#430][lcDebugDescription(request:)]: 
------ BEGIN LeanCloud HTTP Response
task: 4
code: 200
data: {
  "groupId" : "g0",
  "groupUrl" : "https:\/\/router-g0-push.leancloud.cn",
  "secondary" : "wss:\/\/cn-n1-cell2.leancloud.cn\/",
  "ttl" : 10800,
  "server" : "wss:\/\/A2NVO31p.rtm.lncld.net"
}
------ END
[💛][verbose][LeanCloud][2021-06-21 18:11:42.750][RTMConnection.swift][#1064][websocketHttpUpgrade(socket:request:)]: 
<LeanCloud.WebSocket: 0x7fef892153d0>
GET / HTTP/1.1
Host: A2NVO31p.rtm.lncld.net:443
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: eWFuamV4aW1oZml4cmV1Zg==
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits; server_max_window_bits=15
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Protocol: lc.protobuf2.3


[💙][debug][LeanCloud][2021-06-21 18:11:42.783][HTTPClient.swift][#430][lcDebugDescription(request:)]: 
------ BEGIN LeanCloud HTTP Response
task: 3
code: 200
data: {
  "results" : [
    {
      "test" : "23131233123123dsad",
      "chattingMembers" : [

      ],
  "unChattingMembers" : [

  ],
  "updatedAt" : "2021-06-20T08:55:32.083Z",
  "createdAt" : "2021-06-19T17:32:41.112Z",
  "team" : {
    "__type" : "Pointer",
    "className" : "Team",
    "objectId" : "60cdb94d8f119d3e259d05d1"
  },
  "objectId" : "60ce2a39a06dc908f01f391d"
}
  ]
}
------ END
[<LeanCloud.LCObject: 0x600002a80a80>]
[💛][verbose][LeanCloud][2021-06-21 18:11:43.053][RTMConnection.swift][#1071][websocketHttpUpgrade(socket:response:)]: 
<LeanCloud.WebSocket: 0x7fef892153d0>
HTTP/1.1 101 Switching Protocols
Server: openresty
Date: Mon, 21 Jun 2021 10:11:43 GMT
Connection: upgrade
upgrade: websocket
sec-websocket-accept: H7urCvheP/Vq2z8wFa4rgJWj7Es=
sec-websocket-protocol: lc.protobuf2.3


[💛][verbose][LeanCloud][2021-06-21 18:11:43.054][RTMConnection.swift][#987][websocketDidConnect(socket:)]: 
<LeanCloud.WebSocket: 0x7fef892153d0>
    - did connect
[💛][verbose][LeanCloud][2021-06-21 18:11:43.055][RTMConnection.swift][#364][check(pingPong:)]: 
<LeanCloud.WebSocket: 0x7fef892153d0>
    - ping sent
[💙][debug][LeanCloud][2021-06-21 18:11:43.056][RTMConnection.swift][#702][send(command:service:peerID:callingQueue:callback:)]: 
------ BEGIN LeanCloud Out Command
<LeanCloud.WebSocket: 0x7fef892153d0>
Service: 1
LeanCloud.IMGenericCommand:
cmd: login
appId: "A2NVO31pitasJoNEmaIIMPTn-gzGzoHsz"
i: 1
installationId: "livequery-e8a4ca4e-693a-4065-8deb-8d949532cca9"
service: 1
clientTs: 1624270303054

------ END
[💛][verbose][LeanCloud][2021-06-21 18:11:43.095][RTMConnection.swift][#377][receivePong()]: 
<LeanCloud.WebSocket: 0x7fef892153d0>
    - pong received
[💙][debug][LeanCloud][2021-06-21 18:11:43.134][RTMConnection.swift][#1023][websocketDidReceiveData(socket:data:response:)]: 
------ BEGIN LeanCloud In Command
<LeanCloud.WebSocket: 0x7fef892153d0>
LeanCloud.IMGenericCommand:
cmd: loggedin
appId: "A2NVO31pitasJoNEmaIIMPTn-gzGzoHsz"
i: 1
installationId: "livequery-e8a4ca4e-693a-4065-8deb-8d949532cca9"
service: 1
117 {
  1: 0
}

------ END
2021-06-21 18:11:43.136185+0800 Yanxishe[68543:3531193] CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
    class = inet;
    "m_Limit" = "m_LimitAll";
    ptcl = htps;
    "r_Attributes" = 1;
    sdmn = "dev-api.suoxue.today";
    srvr = "dev-api.suoxue.today";
    sync = syna;
}
[💙][debug][LeanCloud][2021-06-21 18:11:43.137][HTTPClient.swift][#410][lcDebugDescription()]: 
------ BEGIN LeanCloud HTTP Request
task: 5
curl: curl -v \
	-X POST \
	-H "X-LC-Session: 2uqopooxtc2b57hptq3kiu2ua" \
	-H "X-LC-Id: A2NVO31pitasJoNEmaIIMPTn-gzGzoHsz" \
	-H "Content-Type: application/json" \
	-H "X-LC-Prod: 1" \
	-H "Accept: application/json" \
	-H "X-LC-Sign: 6fcd4da493e370716c9d951be3948fd9,1624270303134" \
	-H "User-Agent: LeanCloud-Swift-SDK/17.8.0" \
	-d "{\"clientTimestamp\":1624270303054,\"id\":\"livequery-e8a4ca4e-693a-4065-8deb-8d949532cca9\",\"query\":{\"className\":\"TeamRoom\",\"where\":{\"$and\":[{\"team\":{\"__type\":\"Pointer\",\"className\":\"LCObject\",\"objectId\":\"60cdb94d8f119d3e259d05d1\"}}]}},\"sessionToken\":\"2uqopooxtc2b57hptq3kiu2ua\"}" \
	"https://dev-api.suoxue.today/1.1/LiveQuery/subscribe"
------ END
[💙][debug][LeanCloud][2021-06-21 18:11:43.205][HTTPClient.swift][#430][lcDebugDescription(request:)]: 
------ BEGIN LeanCloud HTTP Response
task: 5
code: 200
data: {
  "id" : "livequery-e8a4ca4e-693a-4065-8deb-8d949532cca9",
  "query_id" : "d343673526327f1c0d7bbfb2e92a38f4"
}
------ END
订阅成功

日志看起来没什么问题。请问「无法收到事件」这种情况是能稳定的复现吗?

是的,是稳定收不到事件。
至今收到事件 0 次。

我也遇到了同样的问题,请问这个问题解决了吗

我也遇到了同样的问题,请问这个问题解决了吗