提问人:user22694486 提问时间:10/6/2023 最后编辑:user22694486 更新时间:11/15/2023 访问量:83
ActionCable无法传递消息的IOS问题
IOS issue with ActionCable not delivering messages
问:
我们注意到,使用17.0.x版本的IOS用户在使用ActionCable on Rails时,几乎有50%的消息没有传递。
我们收到以下消息。
D 2023-10-06T07:21:42.075Z context=node sid=kNJYv6SokFfI9dy9T1E9mK Perform result: &{[] false [] false []}
D 2023-10-06T07:21:42.198Z context=node sid=kNJYv6SokFfI9dy9T1E9mK Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"action":"read"}}
W 2023-10-06T07:21:42.198Z context=node sid=kNJYv6SokFfI9dy9T1E9mK Unknown subscription {"channel":"ConversationChannel","conversation_id":1512}
D 2023-10-06T07:25:48.772Z context=node sid=kNJYv6SokFfI9dy9T1E9mK Websocket close error: websocket: close 1006 (abnormal closure): unexpected EOF
D 2023-10-06T07:25:48.772Z context=node sid=kNJYv6SokFfI9dy9T1E9mK websocket session completed
D 2023-10-06T07:25:48.772Z channel={"conversation_id":1512,"channel":"ConversationChannel"} context=hub sid=kNJYv6SokFfI9dy9T1E9mK Unsubscribed
D 2023-10-06T07:25:48.772Z context=hub sid=kNJYv6SokFfI9dy9T1E9mK Unregistered
D 2023-10-06T07:25:48.772Z context=node sid=kNJYv6SokFfI9dy9T1E9mK Disconnect {"current_user":"Z2lkOi8vbXlqb2Jub3cvVXNlci8zMzY4"} /cable [{"conversation_id":1512,"channel":"ConversationChannel"}]
D 2023-10-06T07:25:48.774Z context=rpc Disconnect response: status:SUCCESS
D 2023-10-06T07:26:50.129Z context=rpc Authenticate response: status:SUCCESS identifiers:"{\"current_user\":\"Z2lkOi8vbXlqb2Jub3cvVXNlci8zMzY4\"}" transmissions:"{\"type\":\"welcome\"}"
D 2023-10-06T07:26:50.129Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg websocket session established
D 2023-10-06T07:26:50.129Z context=hub sid=mAfQYjytdw5yO1QHHTJ1dg Registered with identifiers: {"current_user":"Z2lkOi8vbXlqb2Jub3cvVXNlci8zMzY4"}
D 2023-10-06T07:26:50.348Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{subscribe {"channel":"ConversationChannel","conversation_id":1512} }
D 2023-10-06T07:26:50.354Z context=rpc Command response: status:SUCCESS streams:"conversation_1512" transmissions:"{\"identifier\":\"{\\\"channel\\\":\\\"ConversationChannel\\\",\\\"conversation_id\\\":1512}\",\"type\":\"confirm_subscription\"}"
D 2023-10-06T07:26:50.354Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Subscribed to channel: {"channel":"ConversationChannel","conversation_id":1512}
D 2023-10-06T07:26:50.354Z channel={"channel":"ConversationChannel","conversation_id":1512} context=hub sid=mAfQYjytdw5yO1QHHTJ1dg stream=conversation_1512 Subscribed
D 2023-10-06T07:26:50.426Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"action":"read"}}
D 2023-10-06T07:26:50.447Z context=rpc Command response: status:SUCCESS
D 2023-10-06T07:26:50.447Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Perform result: &{[] false [] false []}
D 2023-10-06T07:27:05.902Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"text":"Dsdwasdad","uuid":"EFFFEADD-40D3-4D68-8E39-1303F7E68B30","action":"send_message"}}
D 2023-10-06T07:27:05.994Z context=pubsub Incoming pubsub message from Redis: {"stream":"conversation_1512","data":"{\"action\":\"new_message\",\"payload\":{\"msg\":{\"text\":\"Dsdwasdad\"}}}"}
D 2023-10-06T07:27:05.994Z context=node Incoming pubsub message: &{conversation_1512 {"action":"new_message","payload":{"msg":{"text":"Dsdwasdad",}}}}
D 2023-10-06T07:27:05.994Z context=hub stream=conversation_1512 Broadcast message: {"action":"new_message","payload":{"msg":{"text":"Dsdwasdad",}}}}
D 2023-10-06T07:27:05.997Z context=rpc Command response: status:SUCCESS
D 2023-10-06T07:27:05.997Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Perform result: &{[] false [] false []}
D 2023-10-06T07:27:06.130Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"action":"read"}}
D 2023-10-06T07:27:06.150Z context=rpc Command response: status:SUCCESS
D 2023-10-06T07:27:06.150Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Perform result: &{[] false [] false []}
D 2023-10-06T07:27:07.824Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"conversation_id":1512,"channel":"ConversationChannel"} {"uuid":"D192F95C-C20E-4B12-9D83-9076EE9CA378","text":"Dasdw","action":"send_message"}}
W 2023-10-06T07:27:07.824Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Unknown subscription {"conversation_id":1512,"channel":"ConversationChannel"}
D 2023-10-06T07:27:10.754Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"conversation_id":1512,"channel":"ConversationChannel"} {"text":"Dassss","uuid":"1FD4DF7F-6DD1-4326-AA50-87CFA917C7A7","action":"send_message"}}
W 2023-10-06T07:27:10.754Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Unknown subscription {"conversation_id":1512,"channel":"ConversationChannel"}
D 2023-10-06T07:27:13.166Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"uuid":"E4053CD5-A614-4D51-8927-5D3E6D611875","text":"Dddwdwa","action":"send_message"}}
D 2023-10-06T07:27:13.239Z context=pubsub Incoming pubsub message from Redis: {"stream":"conversation_1512","data":"{\"action\":\"new_message\",\"payload\":{\"msg\":{\"text\":\"Dddwdwa\",}}
D 2023-10-06T07:27:13.239Z context=node Incoming pubsub message: &{conversation_1512 {"action":"new_message","payload":{"msg":{"text":"Dddwdwa""conversation_id":1512,"timestamp":"2023-10-06T07:27:13+00:00","uuid":"E4053CD5-A614-4D51-8927-5D3E6D611875","type":{"name":"text","text":"Dddwdwa"}}}}
D 2023-10-06T07:27:13.239Z context=hub stream=conversation_1512 Broadcast message: {"action":"new_message","payload":{"msg":{"text":"Dddwdwa","conversation_id":1512,"timestamp":"2023-10-06T07:27:13+00:00","uuid":"E4053CD5-A614-4D51-8927-5D3E6D611875","type":{"name":"text","text":"Dddwdwa"} }}}
D 2023-10-06T07:27:13.241Z context=rpc Command response: status:SUCCESS
D 2023-10-06T07:27:13.241Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Perform result: &{[] false [] false []}
D 2023-10-06T07:27:13.375Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"action":"read"}}
D 2023-10-06T07:27:13.396Z context=rpc Command response: status:SUCCESS
D 2023-10-06T07:27:13.396Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Perform result: &{[] false [] false []}
D 2023-10-06T07:27:16.662Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"conversation_id":1512,"channel":"ConversationChannel"} {"action":"send_message","uuid":"E5618963-1CA1-4EB3-BAB9-196590F35A7B","text":"Asdwadasdwa"}}
W 2023-10-06T07:27:16.662Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Unknown subscription {"conversation_id":1512,"channel":"ConversationChannel"}
D 2023-10-06T07:27:26.078Z context=node sid=mAfQYjytdw5yO1QHHTJ1dg Incoming message: &{message {"channel":"ConversationChannel","conversation_id":1512} {"text":"Dsdsds\n","uuid":"C52C1FA9-B495-44C4-B4E4-2A8D97AEE4B9","action":"send_message"}}
D 2023-10-06T07:27:26.153Z context=pubsub Incoming pubsub message from Redis: {"stream":"conversation_1512","data":"{\"action\":\"new_message\",\"payload\":{\"msg\":{\"text\":\"Dsdsds\\n\"}
附上所执行测试的屏幕截图。
因此,这些消息不会传递给IOS用户。
库版本
服务器端:Rails v6,AnyCable v0.6.5
客户端Websocket的IOS库:Starscream(最初在v3.1.1上),然后在v4.0.6上问题仍然存在。
我们已经确定问题可能出在IOS版本上,因为在以前的版本16.x上,15.x可以正常工作。此外,在 Android 和 Web 客户端上根本没有问题。
任何见解/建议在这里都非常有帮助。
答:
0赞
palkan
11/15/2023
#1
问题来了:
Subscribed to channel: {"channel":"ConversationChannel","conversation_id":1512}
...
Unknown subscription {"conversation_id":1512,"channel":"ConversationChannel"}
标识符(即 JSON 编码对象)中字段的顺序不同。
AnyCable将标识符视为字符串,它对内部内容没有假设(即,我们不会解码JSON来查找通道)。请参阅协议规范。
您使用哪个客户端库?它似乎没有重用标识符,而是在每次发送命令时对对象执行 JSON 编码——这是错误的。{channel, conversation_id}
也
AnyCable v0.6.5 版本
是宝石版吗?无论如何,它太老了(虽然我认为没有关系)
评论
0赞
Giorgos Kylafas
11/15/2023
那么,标识符是另一个JSON字符串中的JSON字符串,AnyCable解码外部JSON字符串而不是内部JSON字符串?我有这个权利吗?
1赞
palkan
11/28/2023
正确。AnyCable服务器对标识符没有任何假设;从它的角度来看,它只是一个字符串(对于订阅中的所有命令,它必须相同)。它由应用程序服务器决定它是否必须是 JSON 字符串或其他字符串。
评论