<div dir="ltr"><div><div><div>hello,<br><br></div>I would like to thanks for both of you the grate support.<br><br></div>thanks again,<br></div>/Robi<br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-23 11:12 GMT+02:00 Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I've opened a ticket to remember so something will be done eventually. Thanks for helping!<span class=""><br>
<br>
On 06/23/2015 11:11 AM, Graham Hay wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
It's bitten me a few times :(<br>
<br>
On 23 June 2015 at 10:09, Loïc Hoguin <<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a><br></span><span class="">
<mailto:<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>>> wrote:<br>
<br>
    Oh nice catch ahah. We should probably warn when something like this<br>
    happens.<br>
<br>
    On 06/23/2015 11:06 AM, Graham Hay wrote:<br>
<br>
        I think the order of your routes is the problem, try putting<br>
        this line<br>
        <<a href="https://github.com/ethrbh/websocket_2/blob/master/src/websocket_2_app.erl#L17" rel="noreferrer" target="_blank">https://github.com/ethrbh/websocket_2/blob/master/src/websocket_2_app.erl#L17</a>><br>
        last.<br>
<br>
        On 23 June 2015 at 09:56, Loïc Hoguin <<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a><br>
        <mailto:<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>><br></span><div><div class="h5">
        <mailto:<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a> <mailto:<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>>>> wrote:<br>
<br>
             The {error, enoent}, especially there, is probably just<br>
        because the<br>
             browser is trying to fetch the favicon.<br>
<br>
             Your issue is that Websocket won't connect, so it has<br>
        nothing to do<br>
             with cowboy_rest. Try tracing cowboy_websocket or enable<br>
        SASL to<br>
             have more info.<br>
<br>
<br>
             On 06/23/2015 10:28 AM, Robert Balogh wrote:<br>
<br>
                 hello,<br>
<br>
                 First of all I would say I am a beginner in Cowboy web<br>
        server, so<br>
                 probably I made something wrong, that is why I got the<br>
        "fault",<br>
                 what I got.<br>
<br>
                 I would like to build up web page, where the client can<br>
                 communicate to<br>
                 server, and server can do the same to client, if client<br>
        does not<br>
                 send<br>
                 anything to server too. The Cowboy has the websocket<br>
        example,<br>
                 what does<br>
                 what I would like to do.<br>
<br>
                 There is only one thing is missing what I would like to<br>
        have.<br>
                 This is<br>
                 the "frameset". My idea is to build the index.html<br>
        using framsets. I<br>
                 made this changes, and I build up the html files for<br>
        the frames,<br>
                 and of<br>
                 course I set these in the index.html.<br>
<br>
                 Here is how the index.html looks like<br>
                       <html><br>
<br>
                       <head><br>
                       <title>Welcome to Websocket example 2</title><br>
                       </head><br>
<br>
                       <frameset rows="64,*"><br>
                           <frame name="top_frame" noresize="noresize"<br>
        scrolling="no"<br>
                 src="frame_top.html"><br>
                           <frameset cols="450,*"><br>
                               <frame name="left_frame" scrolling="auto"<br>
                 src="frame_left.html"><br>
                               <frame name="right_frame"<br>
        src="frame_right.html"><br>
                           </frameset><br>
                           <noframes><br>
                           <body><br>
<br>
                           </body><br>
                           </noframes><br>
                       </frameset><br>
<br>
                       </html><br>
<br>
                 This is how the priv folder looks like<br>
                 -----------------------------------------------------------<br>
                       ls priv/<br>
                       frame_left.html  frame_right.html  frame_top.html<br>
                 index.html  static<br>
<br>
                 This is how I changed the websocket_2_app:start/2 function<br>
                 -----------------------------------------------------------<br>
                       Dispatch = cowboy_router:compile([<br>
                           {'_', [<br>
<br>
                               {"/", cowboy_static, {priv_file, websocket_2,<br>
                 "index.html"}},<br>
                               {"/[...]", cowboy_static, {priv_dir,<br>
        websocket_2,<br>
                 ""}},<br>
<br>
                               {"/websocket_2", ws_handler_2, []},<br>
                               {"/static/[...]", cowboy_static, {priv_dir,<br>
                 websocket_2,<br>
                 "static"}}<br>
                           ]}<br>
                       ]),<br>
<br>
                 After compile and make release package of the app, I<br>
        can reach the<br>
                 webserver on the port 8080, but some connection does<br>
        not set up<br>
                 correctly. The following texts are present in the browser<br>
                       DISCONNECTED<br>
<br>
                       ERROR: undefined<br>
<br>
                       Connecting to: ws://localhost:8080/websocket_2<br>
<br>
                 I made a dbg trace on all cowboy modules, to start some<br>
        kind of<br>
                 troubleshooting. In the "tons" of printout I can see<br>
        this one.<br>
                 So in the<br>
                 bottom of this, there is an {error,enoent}. It comes<br>
        when tries<br>
                 connect<br>
                 to the socket. But unfortunatelly I do not have idea<br>
        what may<br>
                 cause this :-(<br>
<br>
                 The part of trace<br>
                 -----------------------------------------------------------<br>
                       (<0.177.0>) call<br>
<br>
        cowboy_rest:next({http_req,#Port<0.646>,ranch_tcp,keepalive,<0.177.0>,<<"GET">>,'HTTP/1.1',<br>
                                 {{127,0,0,1},33241},<br>
<br>
        <<"localhost">>,undefined,8080,<<"/websocket_2">>,<br>
                                 [<<"websocket_2">>],<br>
                                 <<>>,undefined,[],<br>
                                 [{<<"host">>,<<"localhost:8080">>},<br>
                                  {<<"connection">>,<<"Upgrade">>},<br>
                                  {<<"pragma">>,<<"no-cache">>},<br>
                                  {<<"cache-control">>,<<"no-cache">>},<br>
                                  {<<"upgrade">>,<<"websocket">>},<br>
<br>
          {<<"origin">>,<<"<a href="http://localhost:8080" rel="noreferrer" target="_blank">http://localhost:8080</a>">>},<br>
                                  {<<"sec-websocket-version">>,<<"13">>},<br>
                                  {<<"user-agent">>,<br>
                                   <<"Mozilla/5.0 (X11; Linux i686)<br>
                 AppleWebKit/537.36<br>
                 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36">>},<br>
                                  {<<"accept-encoding">>,<<"gzip,<br>
        deflate, sdch">>},<br>
<br>
          {<<"accept-language">>,<<"en-US,en;q=0.8">>},<br>
<br>
                 {<<"sec-websocket-key">>,<<"by/gwaQvb/51W7Wa9zrGQg==">>},<br>
                                  {<<"sec-websocket-extensions">>,<br>
                                   <<"permessage-deflate;<br>
                 client_max_window_bits">>}],<br>
                                 [{<<"connection">>,[<<"upgrade">>]}],<br>
<br>
<br>
        undefined,[],waiting,<<>>,undefined,false,waiting,[],<<>>,undefined},{state,[{handler,cowboy_static},<br>
                               {handler_opts,{priv_dir,websocket_2,[]}},<br>
                               {listener,http},<br>
                               {dispatch,[{'_',[],<br>
                                               [{[],[],cowboy_static,<br>
<br>
                   {priv_file,websocket_2,"index.html"}},<br>
<br>
                    {['...'],[],cowboy_static,{priv_dir,websocket_2,[]}},<br>
<br>
                 {[<<"websocket_2">>],[],ws_handler_2,[]},<br>
                                                {[<<"static">>,'...'],<br>
                                                 [],cowboy_static,<br>
<br>
                   {priv_dir,websocket_2,"static"}}]}]}],<br>
                              <<"GET">>,cowboy_static,<br>
<br>
<br>
        {<<"/home/ethrbh/projects/github/websocket_2/_rel/websocket_2/lib/websocket_2-1/priv/websocket_2">>,<br>
                               {error,enoent},<br>
                               []},<br>
<br>
<br>
        undefined,[],undefined,[],undefined,[],undefined,false,undefined,<br>
<br>
          undefined,undefined},#Fun<cowboy_rest.2.41839999>)<br>
                 (Timestamp: {1435,<br>
<br>
                      46126,<br>
<br>
                      935663})<br>
<br>
                 I guess, I did something very wrong, but I did not<br>
        found what is<br>
                 that,<br>
                 thus I would like to get some help from you.<br>
<br>
                 Please find my small project in github:<br>
        <a href="https://github.com/ethrbh/websocket_2" rel="noreferrer" target="_blank">https://github.com/ethrbh/websocket_2</a><br>
<br>
                 thanks for your help,<br>
                 /Robi<br>
<br>
<br>
<br>
                 _______________________________________________<br>
                 Extend mailing list<br>
        <a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a> <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a>><br></div></div>
        <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a><span class=""><br>
        <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a>>><br>
        <a href="https://lists.ninenines.eu/listinfo/extend" rel="noreferrer" target="_blank">https://lists.ninenines.eu/listinfo/extend</a><br>
<br>
<br>
             --<br>
             Loïc Hoguin<br>
        <a href="http://ninenines.eu" rel="noreferrer" target="_blank">http://ninenines.eu</a><br>
             Author of The Erlanger Playbook,<br>
             A book about software development using Erlang<br>
             _______________________________________________<br>
             Extend mailing list<br>
        <a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a> <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a>><br></span>
        <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a><span class=""><br>
        <mailto:<a href="mailto:Extend@lists.ninenines.eu" target="_blank">Extend@lists.ninenines.eu</a>>><br>
        <a href="https://lists.ninenines.eu/listinfo/extend" rel="noreferrer" target="_blank">https://lists.ninenines.eu/listinfo/extend</a><br>
<br>
<br>
<br>
    --<br>
    Loïc Hoguin<br>
    <a href="http://ninenines.eu" rel="noreferrer" target="_blank">http://ninenines.eu</a><br>
    Author of The Erlanger Playbook,<br>
    A book about software development using Erlang<br>
<br>
<br>
</span></blockquote><div class="HOEnZb"><div class="h5">
<br>
-- <br>
Loïc Hoguin<br>
<a href="http://ninenines.eu" rel="noreferrer" target="_blank">http://ninenines.eu</a><br>
Author of The Erlanger Playbook,<br>
A book about software development using Erlang<br>
</div></div></blockquote></div><br></div>