funcool

A channel for discussing and asking questions about Funcool libraries https://github.com/funcool/
niwinz 2016-01-12T07:19:38.000213Z

Hmm

niwinz 2016-01-12T07:20:02.000214Z

very very strange

niwinz 2016-01-12T07:20:16.000215Z

subscribe uses socket behind the scenes

niwinz 2016-01-12T07:21:17.000216Z

so if subscribe works, socket should work in the same way

niwinz 2016-01-12T07:21:32.000217Z

if that error is happens is not because postal client

niwinz 2016-01-12T07:21:48.000218Z

is because your handler returns a http response instead of doing the websocket handshake

niwinz 2016-01-12T07:26:43.000219Z

There no other way to see a clear error because websocket impl in the browser just does that

kenny 2016-01-12T07:46:13.000220Z

@niwinz: Not sure why the server would be returning an http response instead of the websocket handshake. This is my route: [:any "postal" (pc/router #'handlers/postal-handler)] And an example handler:

(defmulti postal-handler
          (fn [ctx frame] (select-keys frame [:type :dest])))
(defmethod postal-handler {:type :subscribe
                           :dest :reports}
  [ctx frame]
  (letfn [(on-connect [{:keys [in out] :as context}]
            (println "connect")
            (go
              (>! out (pc/frame {:value "test"}))))]
    (pc/socket ctx on-connect)))

niwinz 2016-01-12T07:47:36.000222Z

:S

niwinz 2016-01-12T07:48:21.000223Z

Catacumba 0.10.0 does the same? Is for discard something that I have broken in the last release

niwinz 2016-01-12T07:48:29.000224Z

due to memory leak fix on websocket engine

kenny 2016-01-12T07:48:33.000225Z

I'll try 0.10.0 right now

kenny 2016-01-12T07:50:21.000226Z

Getting the same error

niwinz 2016-01-12T07:51:14.000227Z

Hmm ok, it is not related to bug fix

niwinz 2016-01-12T07:53:06.000228Z

Can you paste the both lines you are using to connect to catacumba: the subscribe and the socket ?

niwinz 2016-01-12T07:53:13.000229Z

(from cljs)

niwinz 2016-01-12T07:53:28.000230Z

maybe the bi-directional socket does not reaches that handler

niwinz 2016-01-12T07:53:31.000231Z

and reaches other...

kenny 2016-01-12T07:53:58.000233Z

[instream outbus] (pc/socket client :messages) and bus (pc/subscribe client :messages) where (def client (pc/client (str (.-origin js/location) "/postal")))

niwinz 2016-01-12T07:55:07.000235Z

If you want use bi-directional sockets

niwinz 2016-01-12T07:55:19.000236Z

you should change the {:type :subscribe with {:type :socket

niwinz 2016-01-12T07:55:46.000237Z

the error surelly is hapens because me message arribes but it does not routes to appropiate handler

kenny 2016-01-12T07:56:32.000238Z

That did it :simple_smile: I didn't see that minor detail anywhere in the docs. Did I miss it?

niwinz 2016-01-12T07:57:06.000239Z

Maybe the docs are wrong that is clearly possible

kenny 2016-01-12T07:57:50.000241Z

I think it's just missing that difference. Thanks for the help! :simple_smile:

niwinz 2016-01-12T07:57:58.000242Z

You are welcome!

mitchelkuijpers 2016-01-12T08:10:50.000243Z

How do you guys do error handling with core.async channels with catacumba?

mitchelkuijpers 2016-01-12T08:11:15.000244Z

something along the lines of:

(go
      (let [groups (<! groups-chan)]
        (if (instance? Throwable groups)
          (throw groups)
          (ct/delegate {:groups groups}))))))
does not seem to work because catacumba is obviously listening to the channel

niwinz 2016-01-12T08:16:30.000245Z

hi @mitchelkuijpers! In my code I try to isolate the logic and corresponding possible error raising code in separate functions and in catacumba handlers just use that functions and capture posible errors and return corresponding http request with error...

mitchelkuijpers 2016-01-12T08:17:20.000246Z

Aha that sounds reasonable, I don’t really see a generic solution to this problem. Maybe I should just use a promise

mitchelkuijpers 2016-01-12T08:17:38.000247Z

thnx @niwinz

niwinz 2016-01-12T08:17:57.000248Z

But now I see that there no way to use the generic error handling mechanism that catacumba have... with async values

mitchelkuijpers 2016-01-12T08:18:26.000250Z

Ok no problem

niwinz 2016-01-12T08:18:46.000251Z

This can be used with simple handlers. If simple handler raises an exception that error handler will be executed

mitchelkuijpers 2016-01-12T08:18:55.000252Z

Yes I know we use that

niwinz 2016-01-12T08:19:20.000253Z

I think that this should work in the same way with async results

mitchelkuijpers 2016-01-12T08:19:33.000254Z

Maybe fun to know, we are currenlty running in production for about 3 months now with catacumba: https://marketplace.atlassian.com/plugins/nl.avisi.jira.plugins.relations-for-jira/cloud/overview

mitchelkuijpers 2016-01-12T08:19:48.000256Z

Yes maybe it should but currently it doesn’t right?

niwinz 2016-01-12T08:20:09.000257Z

@mitchelkuijpers: thanks for sharing! It is awesome!

👏 2
niwinz 2016-01-12T08:20:44.000258Z

no, at this moment it does not works, at least with core.async no...

niwinz 2016-01-12T08:21:53.000260Z

It should work with manifold and with promesa (completable future)

mitchelkuijpers 2016-01-12T08:22:02.000262Z

Ow awesome

mitchelkuijpers 2016-01-12T08:22:43.000263Z

Thank you sir

niwinz 2016-01-12T08:23:20.000264Z

\o/

😀 1