{"action":"created","issue":{"url":"https://api.github.com/repos/ninenines/cowboy/issues/778","labels_url":"https://api.github.com/repos/ninenines/cowboy/issues/778/labels{/name}","comments_url":"https://api.github.com/repos/ninenines/cowboy/issues/778/comments","events_url":"https://api.github.com/repos/ninenines/cowboy/issues/778/events","html_url":"https://github.com/ninenines/cowboy/issues/778","id":53331705,"number":778,"title":"Cannot establish a connection from TCP","user":{"login":"ziyouchutuwenwu","id":7458713,"avatar_url":"https://avatars.githubusercontent.com/u/7458713?v=3","gravatar_id":"","url":"https://api.github.com/users/ziyouchutuwenwu","html_url":"https://github.com/ziyouchutuwenwu","followers_url":"https://api.github.com/users/ziyouchutuwenwu/followers","following_url":"https://api.github.com/users/ziyouchutuwenwu/following{/other_user}","gists_url":"https://api.github.com/users/ziyouchutuwenwu/gists{/gist_id}","starred_url":"https://api.github.com/users/ziyouchutuwenwu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ziyouchutuwenwu/subscriptions","organizations_url":"https://api.github.com/users/ziyouchutuwenwu/orgs","repos_url":"https://api.github.com/users/ziyouchutuwenwu/repos","events_url":"https://api.github.com/users/ziyouchutuwenwu/events{/privacy}","received_events_url":"https://api.github.com/users/ziyouchutuwenwu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-04T10:02:52Z","updated_at":"2015-01-04T10:09:24Z","closed_at":null,"body":"hi, i have the same issue with him \r\nhttps://github.com/ninenines/cowboy/issues/646\r\n\r\ni write a erlang websocket demo with cowboy, test it with http://www.websocket.org/echo.html, it works fine.\r\n\r\ni change the cocos2d-x sample code ws url from ws://echo.websocket.org to ws://127.0.0.1:8080/websocket, erlang told me connection terminated with {error,closed}.\r\n\r\ni searched the code and add log, at last i found the suspicious code \r\n\r\ncowboy_websocket.erl,line 211\r\n'\r\nhandler_loop(State=#state{socket=Socket, messages={OK, Closed, Error},\r\n\t\ttimeout_ref=TRef}, Req, HandlerState, SoFar) ->\r\n\treceive\r\n\t\t{OK, Socket, Data} ->\r\n\t\t\tState2 = handler_loop_timeout(State),\r\n\t\t\twebsocket_data(State2, Req, HandlerState,\r\n\t\t\t\t<< SoFar/binary, Data/binary >>);\r\n\t\t{Closed, Socket} ->\r\n%%--------------------------------------------------------------------------\r\n%%here will cause the error code, but i don't know why\r\n\t\t\thandler_terminate(State, Req, HandlerState, {error, closed});\r\n'\r\n\r\nwhen i use cocoa-websocket to do the same test, cowboy has the same issue.\r\ncocoa-websocket url   https://github.com/talkative/cocoa-websocket"},"comment":{"url":"https://api.github.com/repos/ninenines/cowboy/issues/comments/68627672","html_url":"https://github.com/ninenines/cowboy/issues/778#issuecomment-68627672","issue_url":"https://api.github.com/repos/ninenines/cowboy/issues/778","id":68627672,"user":{"login":"essen","id":141739,"avatar_url":"https://avatars.githubusercontent.com/u/141739?v=3","gravatar_id":"","url":"https://api.github.com/users/essen","html_url":"https://github.com/essen","followers_url":"https://api.github.com/users/essen/followers","following_url":"https://api.github.com/users/essen/following{/other_user}","gists_url":"https://api.github.com/users/essen/gists{/gist_id}","starred_url":"https://api.github.com/users/essen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/essen/subscriptions","organizations_url":"https://api.github.com/users/essen/orgs","repos_url":"https://api.github.com/users/essen/repos","events_url":"https://api.github.com/users/essen/events{/privacy}","received_events_url":"https://api.github.com/users/essen/received_events","type":"User","site_admin":false},"created_at":"2015-01-04T10:09:24Z","updated_at":"2015-01-04T10:09:24Z","body":"Actually I remember now, `cocos2d-x` is expecting the server to respond to frames sent over Websocket in a specific manner, and the Websocket example just echoes back. So it closed the connection upon receiving incorrect values, and that has nothing to do with the Websocket protocol."}}