{"action":"created","issue":{"url":"https://api.github.com/repos/swoole/swoole-src/issues/1893","repository_url":"https://api.github.com/repos/swoole/swoole-src","labels_url":"https://api.github.com/repos/swoole/swoole-src/issues/1893/labels{/name}","comments_url":"https://api.github.com/repos/swoole/swoole-src/issues/1893/comments","events_url":"https://api.github.com/repos/swoole/swoole-src/issues/1893/events","html_url":"https://github.com/swoole/swoole-src/issues/1893","id":352093983,"node_id":"MDU6SXNzdWUzNTIwOTM5ODM=","number":1893,"title":"Cannot send message from php client to websocket server","user":{"login":"Shkarbatov","id":1907494,"node_id":"MDQ6VXNlcjE5MDc0OTQ=","avatar_url":"https://avatars3.githubusercontent.com/u/1907494?v=4","gravatar_id":"","url":"https://api.github.com/users/Shkarbatov","html_url":"https://github.com/Shkarbatov","followers_url":"https://api.github.com/users/Shkarbatov/followers","following_url":"https://api.github.com/users/Shkarbatov/following{/other_user}","gists_url":"https://api.github.com/users/Shkarbatov/gists{/gist_id}","starred_url":"https://api.github.com/users/Shkarbatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shkarbatov/subscriptions","organizations_url":"https://api.github.com/users/Shkarbatov/orgs","repos_url":"https://api.github.com/users/Shkarbatov/repos","events_url":"https://api.github.com/users/Shkarbatov/events{/privacy}","received_events_url":"https://api.github.com/users/Shkarbatov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-20T11:25:26Z","updated_at":"2018-08-20T14:12:51Z","closed_at":null,"author_association":"NONE","body":"Hi all, I cannot connect to swoole_websocket_server\r\n\r\n**1. What did you do?**\r\n\r\n**This is my client:**\r\n\r\n```\r\n<script>\r\n    // Then some JavaScript in the browser:\r\n    var ws = new WebSocket('ws://site.ll:9502/?user=tester01');\r\n    ws.onmessage = function(evt) { console.log(evt.data); };\r\n    ws.onopen = function (event) { ws.send('test'); }\r\n</script>\r\n```\r\n\r\n**This is my server:**\r\n\r\n```\r\n$server = new swoole_websocket_server(\"127.0.0.1\", 9502);\r\n\r\n$server->on(\"start\", function ($server) {\r\n    echo \"Swoole http server is started at http://127.0.0.1:9502\\n\";\r\n});\r\n\r\n$server->on('connect', function($server, $req) {\r\n    echo \"connect: {$req}\\n\";\r\n});\r\n\r\n$server->on('open', function($server, $req) {\r\n    echo \"connection open: {$req->fd}\\n\";\r\n});\r\n\r\n$server->on('message', function($server, $frame) {\r\n    echo \"received message: {$frame->data}\\n\";\r\n    $server->push($frame->fd, json_encode([\"hello\", \"world\"]));\r\n});\r\n\r\n$server->on('close', function($server, $fd) {\r\n    echo \"connection close: {$fd}\\n\";\r\n});\r\n\r\n$server->start();\r\n```\r\n\r\n**This is my client:**\r\n\r\n```\r\n$client = new swoole_client(SWOOLE_SOCK_TCP);\r\n\r\nif (!$client->connect('127.0.0.1', 9502)) {\r\n    exit(\"connect failed. Error: {$client->errCode}\\n\");\r\n}\r\n\r\n$client->send(\"hello world\\n\");\r\necho $client->recv();\r\n$client->close();\r\n```\r\n\r\n**2. What did you expect to see?**\r\nI need to send data from php client to php webSocket and than send it to WebClient.\r\n\r\n\r\n**3. What did you see instead?**\r\nServer works fine and I cant send message from WebClient to WebSocket server, but when I try to run php client and connect to my server I receive an error:\r\n> PHP Warning:  Swoole\\Client::recv(): recv() failed. Error: Resource temporarily unavailable [11]\r\n\r\n\r\n**4. What version of Swoole are you using (`php --ri swoole`)?**\r\n\r\n```\r\nswoole support => enabled\r\nVersion => 4.0.4\r\nAuthor => Swoole Group[email: team@swoole.com]\r\ncoroutine => enabled\r\nepoll => enabled\r\neventfd => enabled\r\nsignalfd => enabled\r\ncpu affinity => enabled\r\nspinlock => enabled\r\nrwlock => enabled\r\nasync http/websocket client => enabled\r\npcre => enabled\r\nmutex_timedlock => enabled\r\npthread_barrier => enabled\r\nfutex => enabled\r\n\r\nDirective => Local Value => Master Value\r\nswoole.aio_thread_num => 2 => 2\r\nswoole.display_errors => On => On\r\nswoole.use_namespace => On => On\r\nswoole.use_shortname => On => On\r\nswoole.fast_serialize => Off => Off\r\nswoole.unixsock_buffer_size => 8388608 => 8388608\r\n```\r\n\r\n**5. What is your machine environment used (including version of kernel & php & gcc) ?** \r\n\r\n```\r\nPHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS )\r\nCopyright (c) 1997-2017 The PHP Group\r\nZend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies\r\n    with Zend OPcache v7.0.30-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies\r\n    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans\r\n```\r\n\r\n**6. If you are using ssl, what is your openssl version?**\r\nNot using\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/swoole/swoole-src/issues/comments/414330369","html_url":"https://github.com/swoole/swoole-src/issues/1893#issuecomment-414330369","issue_url":"https://api.github.com/repos/swoole/swoole-src/issues/1893","id":414330369,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDMzMDM2OQ==","user":{"login":"twose","id":25978241,"node_id":"MDQ6VXNlcjI1OTc4MjQx","avatar_url":"https://avatars0.githubusercontent.com/u/25978241?v=4","gravatar_id":"","url":"https://api.github.com/users/twose","html_url":"https://github.com/twose","followers_url":"https://api.github.com/users/twose/followers","following_url":"https://api.github.com/users/twose/following{/other_user}","gists_url":"https://api.github.com/users/twose/gists{/gist_id}","starred_url":"https://api.github.com/users/twose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twose/subscriptions","organizations_url":"https://api.github.com/users/twose/orgs","repos_url":"https://api.github.com/users/twose/repos","events_url":"https://api.github.com/users/twose/events{/privacy}","received_events_url":"https://api.github.com/users/twose/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T14:12:51Z","updated_at":"2018-08-20T14:12:51Z","author_association":"MEMBER","body":"Not support Xdebug now."}}
{"actor":{"display_login":"twose"}}