CoNarrative / precept

A declarative programming framework
MIT License
657 stars 33 forks source link

Fullstack Example: WebSocket error #121

Closed amitnovick closed 5 years ago

amitnovick commented 5 years ago

Hello! I tried to play with the Fullstack example today but unfortunately got some errors. Here are the steps I did:

 $ lein --version
Leiningen 2.9.1 on Java 1.8.0_192 OpenJDK 64-Bit Server VM
 $ lein run
Warning: implicit hook found: lein-cprop.plugin/hooks 
Hooks are deprecated and will be removed in a future version.
read config from resource: "config.edn"
(!) read config from file: ".lein-env", but it is empty
2019-05-07 15:49:29,170 [main] INFO  fullstack.env - 
-=[precept-fullstack started successfully using the development profile]=- 
2019-05-07 15:49:29,264 [main] INFO  luminus.http-server - starting HTTP server on port 3000 
2019-05-07 15:49:29,303 [main] INFO  luminus.repl-server - starting nREPL server on port 7000 
2019-05-07 15:49:29,346 [main] INFO  fullstack.core - #'fullstack.routes.ws/socket started 
2019-05-07 15:49:29,346 [main] INFO  fullstack.core - #'fullstack.routes.ws/router started 
2019-05-07 15:49:29,347 [main] INFO  fullstack.core - #'fullstack.config/env started 
2019-05-07 15:49:29,347 [main] INFO  fullstack.core - #'fullstack.handler/init-app started 
2019-05-07 15:49:29,347 [main] INFO  fullstack.core - #'fullstack.core/http-server started 
2019-05-07 15:49:29,347 [main] INFO  fullstack.core - #'fullstack.core/repl-server started 
 $ lein figwheel
Warning: implicit hook found: lein-cprop.plugin/hooks 
Hooks are deprecated and will be removed in a future version.
Figwheel: Cutting some fruit, just a sec ...
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid :)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Compiling "target/cljsbuild/public/js/app.js" from ["src/cljs" "src/cljc" "env/dev/cljs"]...
Successfully compiled "target/cljsbuild/public/js/app.js" in 3.634 seconds.
Figwheel: Starting CSS Watcher for paths  ["resources/public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app
Figwheel Controls:
          (stop-autobuild)                ;; stops Figwheel autobuilder
          (start-autobuild [id ...])      ;; starts autobuilder focused on optional ids
          (switch-to-build id ...)        ;; switches autobuilder to different build
          (reset-autobuild)               ;; stops, cleans, and starts autobuilder
          (reload-config)                 ;; reloads build config and resets autobuild
          (build-once [id ...])           ;; builds source one time
          (clean-builds [id ..])          ;; deletes compiled cljs target files
          (print-config [id ...])         ;; prints out build configurations
          (fig-status)                    ;; displays current state of system
          (figwheel.client/set-autoload false)    ;; will turn autoloading off
          (figwheel.client/set-repl-pprint false) ;; will turn pretty printing off
  Switch REPL build focus:
          :cljs/quit                      ;; allows you to switch REPL to another build
    Docs: (doc function-name-here)
    Exit: Control+C or :cljs/quit
 Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
To quit, type: :cljs/quit
app:cljs.user=> 

After opening http://localhost:3449/ in Chrome, the following is found in the log of the Chrome DevTools Console:

Installing CLJS DevTools 0.9.0 and enabling features :formatters :hints :async

WebSocket connection to 'ws://localhost:3449/chsk?client-id=5023f2e2-80c4-41ce-a666-5126b9cbdc04' failed: Error during WebSocket handshake: Unexpected response code: 404
(anonymous) @ sente.cljc:1019

ERROR [taoensso.sente:1035] - WebSocket error: [object Event]
(anonymous) @ core.cljs:152

WARN [taoensso.sente:1011] - Chsk is closed: will try reconnect attempt (1) in 1498 ms
(anonymous) @ core.cljs:152

 WebSocket connection to 'ws://0.0.0.0:3232/chsk?client-id=c03e5445-802f-4c73-ace0-27fa7a80e2ef' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
(anonymous) @ sente.cljc:1019

ERROR [taoensso.sente:1035] - WebSocket error: [object Event]
(anonymous) @ core.cljs:152

WARN [taoensso.sente:1011] - Chsk is closed: will try reconnect attempt (1) in 1364 ms

WebSocket connection to 'ws://0.0.0.0:3232/chsk?client-id=c03e5445-802f-4c73-ace0-27fa7a80e2ef' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED 
(anonymous) @ sente.cljc:1019

...
alex-dixon commented 5 years ago

Sorry about that. The default start settings for that example now include dev tools: true. You should be able to get rid of those errors by omitting it or setting explicitly to false (though I’d expect the example to still run with those socket errors). If you want the dev tools to connect with the app you should be able to clone and run the server and client from https://github.com/CoNarrative/precept-devtools.

amitnovick commented 5 years ago

Sorry about that. The default start settings for that example now include dev tools: true. You should be able to get rid of those errors by omitting it or setting explicitly to false (though I’d expect the example to still run with those socket errors). If you want the dev tools to connect with the app you should be able to clone and run the server and client from https://github.com/CoNarrative/precept-devtools.

Hi! thanks for your reply and work on this project which I hope to be able to use.

I believe your suggestion referred to this snippet of code on fullstack.core namespace in the cljs directory:

(defn init! []
  (mount/start)
  (start! {:session app-session
           :facts [[:transient :start true]]
           :devtools false}) ; <= changed from `true` to `false`
  (mount-components))

Unfortunately the errors still persist and the app is not quite usable from my interactions with it. This is what it looks like in my browser:

precept-fullstack-example

alex-dixon commented 5 years ago

@feelextra Have you tried viewing it at localhost:3000?

amitnovick commented 5 years ago

@feelextra Have you tried viewing it at localhost:3000?

D'oh! somehow I glossed over that port number.

Thanks for helping me figure it out, it's running now and looks much better, too.

I think I was trying port 3449 because that's what the output of Figwheel points at. Actually, it's weird because as is shown in the screenshot above there is actually some HTML served at that URL, so I just assumed that the app is broken when none of the widgets responded to interactions.

Anyway, I'm excited to get to play with this now :-)