Issue Cowboy Server

205 views
Skip to first unread message

hunt.b...@gmail.com

unread,
Jan 31, 2014, 5:57:13 PM1/31/14
to chica...@googlegroups.com
Hi all, I'm following the "Chicago Boss: A Rough Introduction" tutorial and am having issues getting the hello world to run.  I'm running CB on Debian 7.

I get the following error on running "./init-dev.sh" and trying to access localhost:8001/greeting/hello:

20:34:57.019 [warning] lager_error_logger_h dropped 81 messages in the last second that exceeded the limit of 50 messages/sec
20:34:57.019 [error] Error in process <0.861.0> on node 'cb_tutorial@H-Master' with exit value: {{badmatch,false},[{cowboy_router,execute,2,[{file,"src/cowboy_router.erl"},{line,170}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}


20:34:57.020 [error] Ranch listener boss_http_listener had connection process started with cowboy_protocol:start_link/4 at <0.861.0> exit with reason: {{badmatch,false},[{cowboy_router,execute,2,[{file,"src/cowboy_router.erl"},{line,170}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}

Any ideas?  Thanks all,
Hunt

Hunt Graham

unread,
Feb 4, 2014, 11:52:50 AM2/4/14
to chica...@googlegroups.com
Anyone?

David Welton

unread,
Feb 4, 2014, 11:58:38 AM2/4/14
to chica...@googlegroups.com
Maybe you can post a bit more information about what you are trying to
do, and what your code looks like?

I would try and make sure your code runs ok by first doing something
really simple.

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

Hunt Graham

unread,
Feb 4, 2014, 2:59:35 PM2/4/14
to chica...@googlegroups.com
Sorry I should have been more specific.  All I have is a single controller src/controller/cb_tutorial_greeting_controller.erl.

This is from the Chicago Boss: A Rough Tutorial pdf.  I literally can't even get the "Hello World" to work!  I think its a compiling issue though... I had to run make 3 times for it finish succesfully.

My linux box is at home so I'll post the 'make' output when I get back.  Thanks.  Here's the code in the controller:

-module(cb_tutorial_greeting_controller, [Req]).
-compile(export_all).

hello('GET', []) ->
 {output, "Hello, world!"}.

Kai Janson

unread,
Feb 4, 2014, 3:32:16 PM2/4/14
to chica...@googlegroups.com
By any chance, did you rename the directory that the code lives in?
--Kai

Sent from my non-google-device
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/4f7a7a77-02e4-4052-870c-c627ffef9f5a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hunt Graham

unread,
Feb 4, 2014, 6:57:52 PM2/4/14
to chica...@googlegroups.com
Nope, still the same name.

Cuong Thai

unread,
Feb 5, 2014, 4:59:38 AM2/5/14
to chica...@googlegroups.com
Hi Hunt Graham,

There's an error when compiling latest development version, so download v8.9.0 and follow the tutorial.
I've checked, there's no problem with cb_tutorial app.

Make sure you don't miss request parameter:

-module(cb_tutorial_greeting_controller, [Req]).


Regards,
Cuong Th.

Hunt Graham

unread,
Feb 5, 2014, 2:11:34 PM2/5/14
to chica...@googlegroups.com
Thanks for the response Cuong.  I just tried downloading that, decompressing it, and then run 'make'.  It compiles for a while and then I get the following error:

ERROR: Compiling template src/boss/boss_html_error_template.dtl failed:
  {ok,boss_html_error_template}
ERROR: compile failed while processing /home/hunt/ChicagoBoss-0.8.9: rebar_abort
make: *** [all] Error 1

Just to be specific I downloaded the "ChicagoBoss-0.8.9.tar.gz" stable version.  This is the compile error I got before-- If I run it again and then again it will finish successfully but then the server won't run properly.

Kai Janson

unread,
Feb 5, 2014, 10:01:02 PM2/5/14
to chica...@googlegroups.com
Makes me wonder which version of erlang you're running and how you installed it.  Maybe get a fresh copy for your OS from erlang-solutions.com.

Get 16B02 and try again.
--Kai

Sent from my tricorder
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.

Cuong Thai

unread,
Feb 5, 2014, 10:37:49 PM2/5/14
to chica...@googlegroups.com
Hi Kai Janson,

I've downloaded v0.8.9 again and got same error with Hunt Graham when running make (R16B02)

ERROR: Compiling template src/boss/boss_html_error_template.dtl failed:
  {ok,boss_html_error_template}
ERROR: compile failed while processing /home/cuongth/workspace/ChicagoBoss-0.8.9: rebar_abort

make: *** [all] Error 1

Bor mentioned in CB working on "R16B03" but fails on latest erlydtl topic. Currently we have to get erlydtl v0.8.0

in ChicagoBoss-0.8.9/deps/boss_db/rebar.config, replace following line

{erlydtl, ".*",   {git, "git://github.com/erlydtl/erlydtl.git", "HEAD"}},

by

{erlydtl, ".*",   {git, "git://github.com/erlydtl/erlydtl.git", {tag, "0.8.0"}}},

remove current erlydtl

rm -rf deps/erlydtl

get erlydtl v0.8.0

./rebar get-deps

then you can compile

make clean && make

Regards,
Cuong Th.

Hunt Graham

unread,
Feb 6, 2014, 1:37:00 AM2/6/14
to chica...@googlegroups.com
Finally!!  It works.  [Huge Sigh of Relief]  Much thanks.

As a side note, the code in tutorial doesn't work either unless you add a template to the views directory.

Thanks again Cuong!

Cuong Thai

unread,
Feb 6, 2014, 5:29:31 AM2/6/14
to chica...@googlegroups.com
Hi team,

Someone runs make 3 times then success to build CB, because it ignores errors when compiling 3 dtl files.
Reason: returned values in erlytpl have been changed.
Fail to compile with latest erlydtl issue has been opened.
It need to be fixed soon then people can get CB to work.

Regards,
Cuong Th.

Hunt Graham

unread,
Feb 7, 2014, 10:42:04 AM2/7/14
to chica...@googlegroups.com
Hey Cuong,

Could you try passing a value to a template with this build?  I think erlydtl may not be compiling correctly.

I have this in hello.dtl:

<h1>Hello!</h1>
{{ greeting }}

And this in my controller:


hello('GET', []) ->
          {ok, [{greeting, "Hows it going?"}]}.

The "Hello" shows up but greeting is nowhere to be found.  I have a feeling the constructor is not even firing because this code:

hello('GET', [] ) ->
          {output, "Hello World"}.

causes an error telling me no template is found.  It will work however if I put in a view called hello.html.

Hunt Graham

unread,
Feb 7, 2014, 3:41:42 PM2/7/14
to chica...@googlegroups.com
I meant "controller" not "constructor" in the above post.

Cuong Thai

unread,
Feb 7, 2014, 9:57:38 PM2/7/14
to chica...@googlegroups.com
Hi Hunt Graham,

1. With output return, we don't need template for view

hello('GET', []) ->
  {output, "<html><head></head><body><div>Hello world!</div></body></html>"}.

It already returns template.

2. With defined function above, GET request to localhost:8001/greeting/hello maps with that unique action "hello" of controller "greeting". In tutorial, Evan just shows 3 returned options: output, json, ok that CB provides. If you want to test with ok, you should add new action:

salut('GET', []) ->
  {ok, [{greeting, "Hello, world!"}]}.

In this case you should create template view/greeting/salut.dtl (or salut.html) with content

<h1>Hello!</h1>
{{ greeting }}

Now you can open localhost:8001/greeting/salut
Regards,
Cuong Th.

Hunt Graham

unread,
Feb 8, 2014, 5:54:29 PM2/8/14
to chica...@googlegroups.com
Thanks again for the response Cuong.

If I put in a route within a controller with the output format ( {output, "hello world}. ) I get the following error message:

The requested template ("src/view/animal/heyo.{dtl,html,txt,js,jade,eex}") was not found. If you controller did not run, check that it was exported Additionally, no handler was found for processing 404 errors. You probably want to modify /home/hunt/cboss/cb_tut/priv/cb_tut.routes to prevent errors like this one.

If I put a view in the appropriate sub directory that view renders but will not have anything to do with "hello world" placed in the controller.

Cuong Thai

unread,
Feb 8, 2014, 10:57:42 PM2/8/14
to chica...@googlegroups.com
Hi Hunt,

According to error message, action "heyo" of controller "animal" requires template in view folder. Are you sure in <your app>_animal_controller.erl, heyo function returns ok tag ?

heyo('GET', []) -> {output, "hello world"}. %% Don't miss "

Maybe your "heyo" return ok or json tag?

Regards,
Cuong Th.

Hunt Graham

unread,
Feb 9, 2014, 7:04:35 PM2/9/14
to chica...@googlegroups.com
Never mind fixed it.  It was a compile issue.

This time, I downloaded the zip, changed the line in rebar.config, and then ran make and it worked.
Reply all
Reply to author
Forward
0 new messages