funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
kenny 2016-03-18T01:02:27.000033Z

You should add 0.5.0 to the changelog for postal.

niwinz 2016-03-18T06:02:03.000034Z

I will do it today. Additionally I will updare its dependencies ;)

kenny 2016-03-18T07:48:53.000035Z

@niwinz: I am trying to setup a postal handler like so: (pc/router (partial postal-handler !db)), however, I am getting an error when a client tries to connect No method in multimethod 'attach-route' for dispatch value: ratpack.handling.internal.NcsaRequestLogger@88f0f03. partial works with multimethods. Is there something happening internally that could be causing this?

niwinz 2016-03-18T07:52:28.000037Z

It seems like your dispatch funcion in the multimethod expect somethig different for first parameter

niwinz 2016-03-18T07:52:44.000038Z

seems that the problem comes from thre multimethod dispatch function

kenny 2016-03-18T07:53:17.000039Z

(defmulti postal-handler (fn [_ _ frame]
                           (select-keys frame [:type :dest])))

kenny 2016-03-18T07:53:42.000040Z

I don't think that would cause that error

niwinz 2016-03-18T07:54:37.000041Z

oh, I'm wrong. the error is happening in other side...

niwinz 2016-03-18T07:54:58.000042Z

is on attach-route multimethod.. (catacumba internals).

kenny 2016-03-18T07:55:03.000043Z

Right

kenny 2016-03-18T07:56:15.000044Z

If it's any help, here are my routes:

(ct/routes
    [[(misc/log)]
     [:any (misc/autoreloader)]
     [:error all-error-handler]
     [:assets "" {:dir     "target"
                  :indexes ["index.html"]}]
     [:any "db" (pc/router (partial postal-handler !db))]])

niwinz 2016-03-18T07:56:42.000045Z

:S

niwinz 2016-03-18T07:58:21.000046Z

I don't seems like related to logger

niwinz 2016-03-18T07:58:34.000047Z

Oh seems like you have missed :any

niwinz 2016-03-18T07:58:43.000048Z

on the first routing entry maybe?

kenny 2016-03-18T07:59:01.000050Z

Do I need it? Doesn't have it here: https://funcool.github.io/catacumba/latest/#request-logging

niwinz 2016-03-18T07:59:31.000051Z

Try put :any , maybe is a documentation bug

kenny 2016-03-18T08:00:21.000052Z

Sorta worked. Old error is gone. Client is having problems connecting:

WebSocket connection to '<ws://localhost:4545/db?d=WyJeICIsIn46ZGF0YSIsbnVsbCwifjpkZXN0IiwifjpkYiIsIn46dHlwZSIsIn46c3Vic2NyaWJlIl0.>' failed: Error during WebSocket handshake: Unexpected response code: 200

niwinz 2016-03-18T08:01:07.000053Z

now, with that error, just check the handler that dispatches that request and ensure that it handshakes to websocket

niwinz 2016-03-18T08:01:35.000054Z

About the log, it is clearly a documentation bug

kenny 2016-03-18T08:01:48.000055Z

Yup :simple_smile:

niwinz 2016-03-18T08:02:40.000056Z

thanks!!

kenny 2016-03-18T08:05:50.000057Z

Not sure why the handler isn't dispatching correctly though.. This is all the code atm:

(defmulti postal-handler (fn [_ _ frame]
                           (println "here")
                           (select-keys frame [:type :dest])))

(defmethod postal-handler {:type :subscribe
                           :dest :db}
  [!db ctx frame]
  (letfn [(on-connect [{:keys [in out]}]
            (println "connected!"))]
    (pc/socket ctx on-connect)))

niwinz 2016-03-18T08:07:06.000058Z

Are you sure that the request arrives here?

kenny 2016-03-18T08:07:36.000059Z

Yes. The req is logged in the console

niwinz 2016-03-18T08:08:06.000060Z

The request is logged but you can't be sure that the request is properly dispatched to this implementation.

niwinz 2016-03-18T08:08:26.000061Z

Just put a println inside and check that is executed

kenny 2016-03-18T08:08:55.000062Z

Ah, I misunderstood the question. No, it does not get to the handler

niwinz 2016-03-18T08:09:52.000063Z

Hmm, the (println "here") is executed?

kenny 2016-03-18T08:10:04.000064Z

No

niwinz 2016-03-18T08:10:08.000065Z

0.o

niwinz 2016-03-18T08:10:39.000066Z

Ok, I see

niwinz 2016-03-18T08:11:02.000067Z

In the routers definition, you have [:any "path" (pc/postal....]

niwinz 2016-03-18T08:11:04.000068Z

this is wrong

niwinz 2016-03-18T08:11:29.000069Z

it should be [:prefix "path" [:any (pc/postal ...]]

niwinz 2016-03-18T08:11:41.000070Z

let me 5 min for check that

niwinz 2016-03-18T08:11:52.000071Z

hmm, no I'm wrong

niwinz 2016-03-18T08:11:58.000072Z

:any accepts path also ..

niwinz 2016-03-18T08:13:50.000073Z

Hmm, please try reorder your routes

niwinz 2016-03-18T08:14:00.000074Z

put your assets after the postal handlers

niwinz 2016-03-18T08:14:21.000075Z

Seems like the assets as does not have path is catching all requests

niwinz 2016-03-18T08:15:06.000076Z

The router is a pipeline, if you put less restrictive rules on top, them will not allow pass requests down...

kenny 2016-03-18T08:18:04.000078Z

Wait... My debugging may be incorrect. I have been stopping and restarting the server but I just restarted the repl and I saw a new "stopping server..." print out. I know calling (.stop srvr) used to stop the server but has a Catacumba update changed this?

niwinz 2016-03-18T08:18:45.000079Z

no, you should use something like reloaded workflow for load new changes

kenny 2016-03-18T08:18:59.000080Z

The routes dont like to reload though

niwinz 2016-03-18T08:19:28.000081Z

the autoreloader handler also should work

niwinz 2016-03-18T08:19:47.000082Z

and for that, the restart is not required

kenny 2016-03-18T08:19:48.000083Z

Also, I just verified this... I called (.stop srvr) and the log printed

25286 [nREPL-worker-0] INFO ratpack.server.RatpackServer - Stopping server...
25307 [nREPL-worker-0] INFO ratpack.server.RatpackServer - Server stopped.
but the server is still running

niwinz 2016-03-18T08:20:03.000084Z

0.o

niwinz 2016-03-18T08:20:55.000086Z

https://github.com/funcool/catacumba/issues/51

niwinz 2016-03-18T08:20:59.000088Z

it should be revised

kenny 2016-03-18T08:21:37.000089Z

Anyways, my error is gone after restarting the repl.

niwinz 2016-03-18T08:21:45.000090Z

@kenny: for use properly the autoreloader handler, you should define the handlers as vars, and pass that vars references to the routes.

kenny 2016-03-18T08:21:51.000091Z

I only got that error because it was running the old version of the server 😛

kenny 2016-03-18T08:22:19.000092Z

Ah okay. I'll try that right now

niwinz 2016-03-18T08:22:34.000093Z

the autoreloader handler does not need any server restart

niwinz 2016-03-18T08:23:03.000094Z

but as I have said previously, only works if you pass var references instead of handler instances directly.

niwinz 2016-03-18T08:23:33.000095Z

About the stop the server, seems very strange because in my own projects, with reloaded workflow, it stops correctly :S

kenny 2016-03-18T08:23:56.000096Z

You should add that to the docs :simple_smile:

kenny 2016-03-18T08:25:07.000097Z

Hmm.. Then how is my project different? You are running in the repl?

niwinz 2016-03-18T08:27:06.000100Z

This is may main ns.

kenny 2016-03-18T08:27:36.000101Z

Where is catacumba?

kenny 2016-03-18T08:28:48.000104Z

Ah. Hmm.. Calling stop works in the repl?

niwinz 2016-03-18T08:28:54.000105Z

yes

niwinz 2016-03-18T08:29:00.000106Z

I will check it again

kenny 2016-03-18T08:29:15.000107Z

I can create a minimum working example of the problem

niwinz 2016-03-18T08:29:35.000108Z

do not worry, I need some time for check that

niwinz 2016-03-18T08:29:49.000109Z

I'm currently on my office time and I don't have time for it

kenny 2016-03-18T08:30:14.000110Z

Okay

niwinz 2016-03-18T08:31:28.000111Z

I have checked and works as expected

niwinz 2016-03-18T08:31:40.000112Z

calling (start) on my repl

niwinz 2016-03-18T08:31:44.000113Z

starts the server

niwinz 2016-03-18T08:31:50.000114Z

and (stop) stops properly the server

kenny 2016-03-18T08:32:33.000115Z

I will create a sandbox test and see if something else is up

niwinz 2016-03-18T08:32:41.000116Z

nice, thanks!

kenny 2016-03-18T08:39:40.000117Z

@niwinz: This behaviour is not happening in my sandbox environment. Must be something special about my current project. Will dive deeper into it tomorrow...

niwinz 2016-03-18T08:40:27.000118Z

Thanks! Let me know about anything

kenny 2016-03-18T08:42:08.000119Z

Will do. BTW, regarding beicon and Clojure. Have you looked at using RxJava for the clojure implementation? I believe it can properly handle back pressure.

niwinz 2016-03-18T08:45:36.000120Z

Unfortunatelly, not. I did't have time for it

jetmind 2016-03-18T14:50:40.000122Z

Hi all! Is my understanding correct that htturr does not support https (at least on a node.js)? Or am I missing something?

2016-03-18T14:55:02.000123Z

now that you mention it I see that if you want an HTTPS client you have to require("https") instead of require("http")

2016-03-18T14:55:11.000124Z

and the node client requires the http one https://github.com/funcool/httpurr/blob/master/src/httpurr/client/node.cljs#L7

2016-03-18T14:56:43.000126Z

if the HTTPS client supports HTTP too I'm happy to accept a patch with the change

2016-03-18T14:57:55.000127Z

otherwise i can make the http module used by the client a dynamic var, similar to Xhr's client's *xhr-impl*

jetmind 2016-03-18T14:58:40.000128Z

I'm not sure if HTTPS client supports HTTP (I'm not very familiar with node) but I suspect you must choose one of them depending on url

2016-03-18T14:59:25.000129Z

that's surprising

2016-03-18T15:00:58.000130Z

if that's the case we can make the http module a dynamic variable

2016-03-18T15:01:29.000131Z

or inspect the URL to see which protocol we're using and use the right module

2016-03-18T15:01:54.000132Z

happy to merge a patch with these changes, otherwise maybe i can address it during the weekend

jetmind 2016-03-18T15:05:08.000133Z

I'll try to create a patch later today

2016-03-18T15:07:49.000134Z

awesome, let me know if you run into any problems

niwinz 2016-03-18T15:16:48.000135Z

In fact, the node client requires a great revision, because is the "less used" and less maintained

jetmind 2016-03-18T15:25:20.000136Z

and lacks any tests AFAICS :simple_smile:

niwinz 2016-03-18T15:32:24.000137Z

sure 😞

jetmind 2016-03-18T16:02:13.000138Z

Sent a pull request https://github.com/funcool/httpurr/pull/6

2016-03-18T16:06:54.000140Z

nice, just merged it and pushed 0.5.0-SNAPSHOT to clojars with the changes; thanks @jetmind!

jetmind 2016-03-18T16:08:30.000141Z

Cool! Thanks for quick release!

jetmind 2016-03-18T16:08:43.000142Z

and for creating the library in the first place)

😡 1