Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Real-time update example from tutorial does not work #152

Closed
eykd opened this Issue Sep 13, 2012 · 4 comments

Comments

Projects
None yet
3 participants

eykd commented Sep 13, 2012

In section IV.3 of the tutorial PDF, the pull greeting/pull/ controller is defined as such:

pull('GET', [LastTimestamp]) ->
    {ok, Timestamp, Greetings} = boss_mq:pull("new-greetings", 
        list_to_integer(LastTimestamp)),
    {json, [{timestamp, Timestamp}, {greetings, Greetings}]}.

However, when a web client is waiting on this to resolve and a new greeting gets sent over the channel, the controller errors out with this:

{function_clause,[{boss_json,json_data1,
                             [[{greeting,"greeting-25","Yo!"}],[],[]]},
                  {boss_json,json_data1,3},
                  {boss_json,encode,2},
                  {boss_web_controller,process_action_result,5},
                  {boss_web_controller,execute_action,5},
                  {boss_web_controller,process_request,5},
                  {timer,tc,3},
                  {boss_web_controller,handle_request,3}]}

I'm extremely new to reading Erlang and Erlang tracebacks, but after playing around with this a bit and attempting to read the code, it seems like the JSON serializer is choking on a list of models.

Since the controller return value json is documented as supporting lists of models, I think this may be a bug. Either that, or something fundamental has changed between 0.7 (the version of the tutorial) and 0.8 (the version for download).

eykd commented Sep 13, 2012

I should mention that after all the usual request/response cycle stuff, this was the part of the tutorial that made me do my best Keanu Reeves impression: "Whoah." I was really bummed when it didn't work. :(

Contributor

pellegrino commented Sep 15, 2012

I'm also having the same problem here. I tried replacing the output to use a simple string instead of a Boss Record and it did work. I guess json encoder didn't like the list of models.

Contributor

pellegrino commented Sep 15, 2012

Update here: i don't know exactly what i did, but this error went away. I probably just restarted my server and cleared the mock database. So i would probably call it as something wrong on my side of things.

Contributor

zkessin commented Jan 26, 2014

I am closing this

@zkessin zkessin closed this Jan 26, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment