small medium large xlarge

26 Jul 2017, 19:06
Justin Calcagni (17 posts)


I have successfully made all the Websockets changes in Ch5 to the guestbook application.

The app compiles & runs however when I go to the localhost: in the browser, I only see the page header

guestbook home about

and none of the other content.

I dont see anything in the console except this message

DEBUG io.undertow.websockets.core.request - UT025003: Decoding WebSocket Frame with opCode 1

I checked my home & base html files to the sample code and they match

any ideas where I should look next to troubleshoot?


26 Jul 2017, 19:55
Dmitri Sotnikov (141 posts)

If you could post the code for the project somewhere, I could take a look. It’s hard to say what the problem is based on the description.

26 Jul 2017, 21:50
Justin Calcagni (17 posts)


I added the app to

I think I pushed all the necessary files.

thank you

26 Jul 2017, 23:32
Dmitri Sotnikov (141 posts)

Looks like one of the problems was that the event-msg-handler in the namespace wasn’t updated to use Sente. The compiler produced the following warnings in the console:

WARNING: Use of undeclared Var! at line 30 /Users/yogthos/src/tmp/guestbook/src/cljs/guestbook/ws.cljs
WARNING: Use of undeclared Var at line 31 /Users/yogthos/src/tmp/guestbook/src/cljs/guestbook/ws.cljs

When you update the the function to look as follows, that problem is resolved:

(defn event-msg-handler [& [{:keys [message state handshake]
                             :or {state state-handler
                                  handshake handshake-handler}}]]
  (fn [ev-msg]
    (case (:id ev-msg)
      :chsk/handshake (handshake ev-msg)
      :chsk/state (state ev-msg)
      :chsk/recv (message ev-msg)
      (default-event-handler ev-msg))))

Another problem is in the guestbook.core namespace in the home function. When you initialize the message-form you’re passing it messages as the argument. However, it expects fields and errors parameters, so it should be called with:

[message-form fields errors]

Finally, on the server side, you’re not starting the router in the namespace, so the server isn’t handling the websocket connection. The following change will fix the issue:

(defn start-router! []
  (sente/start-chsk-router! ch-chsk handle-message!))

(defstate router
  :start (start-router!)
  :stop (stop-router! router))
27 Jul 2017, 14:43
Justin Calcagni (17 posts)

Thank you! I found that code and made the changes (2 were actually there but had typos)

but when I start the server again, I have the same problem. Nothing appears after the header withe “guestbook home about”

28 Jul 2017, 03:34
Dmitri Sotnikov (141 posts)

I was able to get the project running properly locally with the changes. One thing to take a look at would be to make sure that browser cache is cleared. An old version of the client code might still be running.

31 Jul 2017, 16:04
Justin Calcagni (17 posts)

I cleared my browser cache, still no luck. I tried using chrome instead of firefox and have 3 errors in the console for the developer tools

error rendering component (in guestbook.core.home > guestbook.core.message_form > guestbook.core.errors_component) reagent$impl$component$do_render @ component.cljs:69

comes from the ns reagent.impl component the “Error rendering component is triggering”

(defn do-render [c] (binding [current-component c] (if (dev?) ;; Log errors, without using try/catch (and mess up call stack) (let [ok (array false)] (try (let [res (do-render-sub c)] (aset ok 0 true) res) (finally (when-not (aget ok 0) (js/console.error (str “Error rendering component “ (comp-name))))))) (do-render-sub c))))

there are 2 other errors, one in core.cljs and another in react.js.out (not sure if either of those will be helpful)

01 Aug 2017, 04:20
Dmitri Sotnikov (141 posts)

Here’s a pull request with the fixes I made locally. I’m able to run the project run successfully with these changes.

01 Aug 2017, 19:34
Justin Calcagni (17 posts)

Are you using windows? I am not sure if that makes a difference

here is the error I see in DEV tools in firefox & chrome

Error rendering component (in guestbook.core.home > guestbook.core.message_form > guestbook.core.errors_component)

I have the same problem in CH8 with the Modal page (I don’t see the modal page). I even copy.pasted the source code

01 Aug 2017, 21:16
Dmitri Sotnikov (141 posts)

I don’t have Windows. but there’s nothing Windows specific about the error component, so I don’t think that would be the problem. Unfortunately, I can’t reproduce the issue locally, so it’s difficult to say what’s causing it.

You must be logged in to comment