{"action":"created","issue":{"url":"https://api.github.com/repos/walkor/phpsocket.io/issues/55","repository_url":"https://api.github.com/repos/walkor/phpsocket.io","labels_url":"https://api.github.com/repos/walkor/phpsocket.io/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/walkor/phpsocket.io/issues/55/comments","events_url":"https://api.github.com/repos/walkor/phpsocket.io/issues/55/events","html_url":"https://github.com/walkor/phpsocket.io/issues/55","id":193110410,"number":55,"title":"Multiple servers for Development/Production setup","user":{"login":"ptdev","id":1280528,"avatar_url":"https://avatars.githubusercontent.com/u/1280528?v=3","gravatar_id":"","url":"https://api.github.com/users/ptdev","html_url":"https://github.com/ptdev","followers_url":"https://api.github.com/users/ptdev/followers","following_url":"https://api.github.com/users/ptdev/following{/other_user}","gists_url":"https://api.github.com/users/ptdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ptdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptdev/subscriptions","organizations_url":"https://api.github.com/users/ptdev/orgs","repos_url":"https://api.github.com/users/ptdev/repos","events_url":"https://api.github.com/users/ptdev/events{/privacy}","received_events_url":"https://api.github.com/users/ptdev/received_events","type":"User","site_admin":false},"labels":[{"id":244902514,"url":"https://api.github.com/repos/walkor/phpsocket.io/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-02T12:58:04Z","updated_at":"2016-12-02T15:54:15Z","closed_at":"2016-12-02T15:54:15Z","body":"Hi, I have a webapp that uses this socketio implementation for a chat/notification box.\r\n\r\nRecently, I needed to split my app into DEV and PROD versions so I added a check on my server.php to detect the folder name and change ports accordingly.\r\n\r\nSomething like this:\r\n\r\n```\r\n// detect environment\r\n$mode = (strpos(dirname(__DIR__), '-dev') !== false) ? 'dev' : 'prod';\r\n\r\nif($mode === 'dev') {\r\n    $channel = new Channel\\Server('0.0.0.0', 3206);\r\n    $io = new SocketIO(3020);\r\n} elseif($mode === 'prod') {\r\n    $channel = new Channel\\Server('0.0.0.0', 2206);\r\n    $io = new SocketIO(2020);\r\n}\r\n```\r\n\r\nSo, if I run \"server.php start\" inside a folder that has \"-dev\" in the name, it starts the servers on ports 3020/3206, otherwise it will start on ports 2020/2206.\r\n\r\nThis is working fine, but the servers seem to be communicating with each other, because when I type something on the DEV's chat message, the message appears on the PROD and vice-versa.\r\n\r\nI've used Chrome developer tools to check the connections and each version seems to be correctly connected to the different versions, so:\r\n\r\nPROD app at \"myapp.example.com\" is connected to wss://myapp.example.com/socket.io/...\r\nDEV app at \"myapp-dev.example.com\" is connected to wss://myapp-dev.example.com/socket.io/...\r\n\r\nIn case it helps here are the status message for both when there's one user connected to each version:\r\n\r\nDEV:\r\n\r\n```\r\nWorkerman[server.php] status\r\n---------------------------------------GLOBAL STATUS--------------------------------------------\r\nWorkerman version:3.3.4          PHP version:5.6.27-0+deb8u1\r\nstart time:2016-12-02 20:10:37   run 0 days 0 hours\r\nload average: 0.05, 0.05, 0.05   event-loop:select\r\n2 workers       2 processes\r\nworker_name   exit_status     exit_count\r\nChannelServer 0                0\r\nPHPSocketIO   0                0\r\n---------------------------------------PROCESS STATUS-------------------------------------------\r\npid\tmemory  listening               worker_name   connections total_request send_fail throw_exception\r\n3301\t1.75M   frame://0.0.0.0:3206    ChannelServer 0           0              0         0\r\n3302\t2.75M   socketIO://0.0.0.0:3020 PHPSocketIO   3           255            0         0\r\n```\r\n\r\nPROD:\r\n\r\n```\r\nWorkerman[server.php] status\r\n---------------------------------------GLOBAL STATUS--------------------------------------------\r\nWorkerman version:3.3.4          PHP version:5.6.27-0+deb8u1\r\nstart time:2016-12-02 20:10:32   run 0 days 0 hours\r\nload average: 0.12, 0.07, 0.05   event-loop:select\r\n2 workers       2 processes\r\nworker_name   exit_status     exit_count\r\nChannelServer 0                0\r\nPHPSocketIO   0                0\r\n---------------------------------------PROCESS STATUS-------------------------------------------\r\npid\tmemory  listening               worker_name   connections total_request send_fail throw_exception\r\n3295\t1.75M   frame://0.0.0.0:2206    ChannelServer 2           273            0         0\r\n3296\t2.75M   socketIO://0.0.0.0:2020 PHPSocketIO   3           292            0         0\r\n```\r\n\r\n\r\nSo, my question is, how can I run two completely separate versions so I can properly separate my development tests from the production version?\r\n\r\nThank you.\r\n"},"comment":{"url":"https://api.github.com/repos/walkor/phpsocket.io/issues/comments/264487111","html_url":"https://github.com/walkor/phpsocket.io/issues/55#issuecomment-264487111","issue_url":"https://api.github.com/repos/walkor/phpsocket.io/issues/55","id":264487111,"user":{"login":"ptdev","id":1280528,"avatar_url":"https://avatars.githubusercontent.com/u/1280528?v=3","gravatar_id":"","url":"https://api.github.com/users/ptdev","html_url":"https://github.com/ptdev","followers_url":"https://api.github.com/users/ptdev/followers","following_url":"https://api.github.com/users/ptdev/following{/other_user}","gists_url":"https://api.github.com/users/ptdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ptdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptdev/subscriptions","organizations_url":"https://api.github.com/users/ptdev/orgs","repos_url":"https://api.github.com/users/ptdev/repos","events_url":"https://api.github.com/users/ptdev/events{/privacy}","received_events_url":"https://api.github.com/users/ptdev/received_events","type":"User","site_admin":false},"created_at":"2016-12-02T15:54:15Z","updated_at":"2016-12-02T15:54:15Z","body":"Thanks a lot man, that's exactly what I needed, I just couldn't figure out this part:\r\n\r\n`ChannelAdapter::$port = 3206;`\r\n\r\nIt's working perfectly now, thanks again, and great work on your github repos!"}}
{"actor":{"display_login":"ptdev"}}