{"action":"created","issue":{"url":"https://api.github.com/repos/do7be/lgtm-hub/issues/51","repository_url":"https://api.github.com/repos/do7be/lgtm-hub","labels_url":"https://api.github.com/repos/do7be/lgtm-hub/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/do7be/lgtm-hub/issues/51/comments","events_url":"https://api.github.com/repos/do7be/lgtm-hub/issues/51/events","html_url":"https://github.com/do7be/lgtm-hub/pull/51","id":139900947,"number":51,"title":"Web Socketがブラウザとサーバで疎通できない問題を解消","user":{"login":"do7be","id":9024344,"avatar_url":"https://avatars.githubusercontent.com/u/9024344?v=3","gravatar_id":"","url":"https://api.github.com/users/do7be","html_url":"https://github.com/do7be","followers_url":"https://api.github.com/users/do7be/followers","following_url":"https://api.github.com/users/do7be/following{/other_user}","gists_url":"https://api.github.com/users/do7be/gists{/gist_id}","starred_url":"https://api.github.com/users/do7be/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/do7be/subscriptions","organizations_url":"https://api.github.com/users/do7be/orgs","repos_url":"https://api.github.com/users/do7be/repos","events_url":"https://api.github.com/users/do7be/events{/privacy}","received_events_url":"https://api.github.com/users/do7be/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/do7be/lgtm-hub/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/do7be/lgtm-hub/labels/%E3%83%AA%E3%83%AA%E3%83%BC%E3%82%B9","name":"リリース","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-10T14:21:14Z","updated_at":"2016-03-10T14:22:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/do7be/lgtm-hub/pulls/51","html_url":"https://github.com/do7be/lgtm-hub/pull/51","diff_url":"https://github.com/do7be/lgtm-hub/pull/51.diff","patch_url":"https://github.com/do7be/lgtm-hub/pull/51.patch"},"body":"#50\r\nの対応で、ブラウザからはemitできるのにサーバからブラウザに返すと受け取れずランダム画像が表示できないという問題に陥ってしまった。\r\n\r\n## 原因\r\n\r\nブラウザからweb socketのemitを行うようになったが、モジュールが分割されており、同じsocketではなく新たにio()でコネクションを貼ってしまったためだと考えられる。このため、最初のコネクション確立の際のブラウザのsocket.onのコネクションと、画像取得の際のコネクションは異なるものであり、サーバから情報を返信してもブラウザには待ち構えているコネクションがいないため受け取れなかったのだと推測される。\r\n\r\n## 対応\r\n\r\nしょうがないので全部同じモジュールでsocket変数を共有することに。共通クラスのstaticメソッドはそのまま使いまわしたかったので引数でsocketを渡すようにした。\r\n\r\n## 疑問\r\n\r\nこの現象は、フロントにNginx、その後ろにNodeサーバという状態でのみ発生したというのがよくわからなかった。この構成だとWebSocketを橋渡ししているためだろうか？"},"comment":{"url":"https://api.github.com/repos/do7be/lgtm-hub/issues/comments/194869460","html_url":"https://github.com/do7be/lgtm-hub/pull/51#issuecomment-194869460","issue_url":"https://api.github.com/repos/do7be/lgtm-hub/issues/51","id":194869460,"user":{"login":"do7be","id":9024344,"avatar_url":"https://avatars.githubusercontent.com/u/9024344?v=3","gravatar_id":"","url":"https://api.github.com/users/do7be","html_url":"https://github.com/do7be","followers_url":"https://api.github.com/users/do7be/followers","following_url":"https://api.github.com/users/do7be/following{/other_user}","gists_url":"https://api.github.com/users/do7be/gists{/gist_id}","starred_url":"https://api.github.com/users/do7be/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/do7be/subscriptions","organizations_url":"https://api.github.com/users/do7be/orgs","repos_url":"https://api.github.com/users/do7be/repos","events_url":"https://api.github.com/users/do7be/events{/privacy}","received_events_url":"https://api.github.com/users/do7be/received_events","type":"User","site_admin":false},"created_at":"2016-03-10T14:22:06Z","updated_at":"2016-03-10T14:22:06Z","body":"![image](https://cloud.githubusercontent.com/assets/9024344/13672150/e5957836-e716-11e5-82eb-94d5a7e07e0e.png)\r\n"}}