{"action":"created","issue":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18991","repository_url":"https://api.github.com/repos/cocos2d/cocos2d-x","labels_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18991/labels{/name}","comments_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18991/comments","events_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18991/events","html_url":"https://github.com/cocos2d/cocos2d-x/issues/18991","id":351072015,"node_id":"MDU6SXNzdWUzNTEwNzIwMTU=","number":18991,"title":"Lua: webSockets receive information received from other closed sockets","user":{"login":"CarlZhongZ","id":5827910,"node_id":"MDQ6VXNlcjU4Mjc5MTA=","avatar_url":"https://avatars0.githubusercontent.com/u/5827910?v=4","gravatar_id":"","url":"https://api.github.com/users/CarlZhongZ","html_url":"https://github.com/CarlZhongZ","followers_url":"https://api.github.com/users/CarlZhongZ/followers","following_url":"https://api.github.com/users/CarlZhongZ/following{/other_user}","gists_url":"https://api.github.com/users/CarlZhongZ/gists{/gist_id}","starred_url":"https://api.github.com/users/CarlZhongZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CarlZhongZ/subscriptions","organizations_url":"https://api.github.com/users/CarlZhongZ/orgs","repos_url":"https://api.github.com/users/CarlZhongZ/repos","events_url":"https://api.github.com/users/CarlZhongZ/events{/privacy}","received_events_url":"https://api.github.com/users/CarlZhongZ/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"PatriceJiang","id":40414978,"node_id":"MDQ6VXNlcjQwNDE0OTc4","avatar_url":"https://avatars2.githubusercontent.com/u/40414978?v=4","gravatar_id":"","url":"https://api.github.com/users/PatriceJiang","html_url":"https://github.com/PatriceJiang","followers_url":"https://api.github.com/users/PatriceJiang/followers","following_url":"https://api.github.com/users/PatriceJiang/following{/other_user}","gists_url":"https://api.github.com/users/PatriceJiang/gists{/gist_id}","starred_url":"https://api.github.com/users/PatriceJiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PatriceJiang/subscriptions","organizations_url":"https://api.github.com/users/PatriceJiang/orgs","repos_url":"https://api.github.com/users/PatriceJiang/repos","events_url":"https://api.github.com/users/PatriceJiang/events{/privacy}","received_events_url":"https://api.github.com/users/PatriceJiang/received_events","type":"User","site_admin":false},"assignees":[{"login":"PatriceJiang","id":40414978,"node_id":"MDQ6VXNlcjQwNDE0OTc4","avatar_url":"https://avatars2.githubusercontent.com/u/40414978?v=4","gravatar_id":"","url":"https://api.github.com/users/PatriceJiang","html_url":"https://github.com/PatriceJiang","followers_url":"https://api.github.com/users/PatriceJiang/followers","following_url":"https://api.github.com/users/PatriceJiang/following{/other_user}","gists_url":"https://api.github.com/users/PatriceJiang/gists{/gist_id}","starred_url":"https://api.github.com/users/PatriceJiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PatriceJiang/subscriptions","organizations_url":"https://api.github.com/users/PatriceJiang/orgs","repos_url":"https://api.github.com/users/PatriceJiang/repos","events_url":"https://api.github.com/users/PatriceJiang/events{/privacy}","received_events_url":"https://api.github.com/users/PatriceJiang/received_events","type":"User","site_admin":false}],"milestone":null,"comments":9,"created_at":"2018-08-16T06:30:01Z","updated_at":"2018-08-22T03:09:57Z","closed_at":null,"author_association":"NONE","body":"- cocos2d-x version:316 317\r\n- devices test on:all platforms\r\n- developing environments\r\n   - NDK version:\r\n   - Xcode version:\r\n   - VS version:\r\n   - browser type and version:\r\n\r\nWebSocket 当有多个实例的时候出现接收到其他已经关闭的socket的接收的信息的BUG\r\n\r\nSteps to Reproduce:\r\n触发时机如下:\r\n1.lua 中创建一个 websocket: self._conn = cc.WebSocket:create(ADDR) 这里c++的 WebSocket 创建了一个对象实例 指针值为 0xabcdefaa（举个例子），这个socket称之为A\r\n2.执行游戏的重启(因为实现原因，每次重新链接一次需要新创建一个socket),先关闭A,再创建一个websocket B(调用A.close 然后再创建一个 weebsocket B 连接游戏)，如果在A 真正的关闭回调执行前(WebSocket onConnectionClosed  被调用) 被 lua gc (delete A), 然后创建的 B 的 WebSocket 也为 0xabcdefaa (跟之前 A的指针一致)，这时候 B 的socket会收到 A 后续残余收到的部分协议。\r\n\r\n导致这个的原因应该是初始化_wsInstance 设置 绑定 userdata 的时候绑定的是 WebSocket 实例的指针，如果 WebSocket 维护一个 uid 保证每次创建的 WebSocket uid 都保证不一样 用 uid 做为 userdata 在 WebSocketCallbackWrapper 根据 uid 找对应的 websocket 这样应该就不会出现这种情况\r\n\r\nps.这样出现几率很小，影响不会太大"},"comment":{"url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/comments/414894316","html_url":"https://github.com/cocos2d/cocos2d-x/issues/18991#issuecomment-414894316","issue_url":"https://api.github.com/repos/cocos2d/cocos2d-x/issues/18991","id":414894316,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDg5NDMxNg==","user":{"login":"PatriceJiang","id":40414978,"node_id":"MDQ6VXNlcjQwNDE0OTc4","avatar_url":"https://avatars2.githubusercontent.com/u/40414978?v=4","gravatar_id":"","url":"https://api.github.com/users/PatriceJiang","html_url":"https://github.com/PatriceJiang","followers_url":"https://api.github.com/users/PatriceJiang/followers","following_url":"https://api.github.com/users/PatriceJiang/following{/other_user}","gists_url":"https://api.github.com/users/PatriceJiang/gists{/gist_id}","starred_url":"https://api.github.com/users/PatriceJiang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PatriceJiang/subscriptions","organizations_url":"https://api.github.com/users/PatriceJiang/orgs","repos_url":"https://api.github.com/users/PatriceJiang/repos","events_url":"https://api.github.com/users/PatriceJiang/events{/privacy}","received_events_url":"https://api.github.com/users/PatriceJiang/received_events","type":"User","site_admin":false},"created_at":"2018-08-22T03:09:57Z","updated_at":"2018-08-22T03:09:57Z","author_association":"CONTRIBUTOR","body":"According to the websocket protocol, message data can be split into multiple `package` during transferring. could you pls provide more information about the error. "}}
{"actor":{"display_login":"PatriceJiang"}}