tencentyun / wafer

Wafer - 快速构建具备弹性能力的微信小程序
https://github.com/tencentyun/wafer
Other
2.16k stars 332 forks source link

信道接收顺序错乱问题 #38

Open chn-lee-yumi opened 6 years ago

chn-lee-yumi commented 6 years ago

按照我写的服务端代码逻辑, 首先tunnel.broadcast消息A,然后tunnel.broadcast消息B。 在客户端上正常应该先收到A,然后才收到B,但是有时候会先收到B,再收到A。 这种情况怎么处理?

jas0ncn commented 6 years ago

能否贴一下代码看看呢?

chn-lee-yumi commented 6 years ago

服务端代码: 发送20条信息。 qq 20180217013950 客户端接收到11条错乱的信息,丢了9条。 qq 20180217014325 @jas0ncn

jas0ncn commented 6 years ago

额,tunnel.broadcast 是异步的操作,循环一个异步的操作不代表会按顺序,这是异步的特性。建议使用队列。

chn-lee-yumi commented 6 years ago

请问有提供相关的函数吗?服务端发送消息我只看到有broadcast @jas0ncn

chn-lee-yumi commented 6 years ago

我用async实现了顺序执行,不过还是会出现丢包的现象。 下面是服务端的代码: 0 1 2 下面是客户端接收到的信息: 3 测试了5次,100条信息,丢了15条。

jas0ncn commented 6 years ago

方便把服务端broadcast之后的返回打印出来吗?打印出来看一下返回的结果是什么

chn-lee-yumi commented 6 years ago

下面是服务端的代码: qq 20180218233503 qq 20180218233522 下面是客户端收到的信息: qq 20180218233436 @jas0ncn

jas0ncn commented 6 years ago

SDK会把Log打出来: https://github.com/tencentyun/wafer2-node-sdk/blob/2084c4d9839509a1e60eafc4d41c16cc5c5e62d3/lib/tunnel/api.js#L55

可以到腾讯云控制台下载日志: image

看看日志输出的message是什么

chn-lee-yumi commented 6 years ago

原来可以从这里下log…… 下面是log内容: (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 5): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 6): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 7): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 8): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 9): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 10): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 11): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 12): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 13): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 14): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 15): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 16): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 17): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 18): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 20): Error: Request failed with status code 502 (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 21): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 22): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 23): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 24): Error: ERR_REMOTE_TUNNEL_SERVER_RESPONSE (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 25): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 26): Error: ERR_UNKNOWN_TUNNEL_ERROR (node:9200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 27): Error: ERR_UNKNOWN_TUNNEL_ERROR @jas0ncn

jas0ncn commented 6 years ago

这个我们再排查一下