immutant

http://immutant.org Note: dev discussion happens in #immutant on FreeNode IRC.
richiardiandrea 2016-09-14T18:19:43.000070Z

A question about websocket...I was wondering which ws protocol version is supported by org.immutant/web 2.1.5 as I have a weird behaviour with wscat, should I look in undertow 1.3.23 ?

richiardiandrea 2016-09-14T18:21:06.000073Z

so 7-8-13 should be supported

2016-09-14T19:16:22.000074Z

@richiardiandrea: it should be easy enough to bump your undertow version among your deps if you need to

richiardiandrea 2016-09-14T19:31:13.000075Z

@jcrossley3 thanks, I am trying to understand why my connection gets disconnected right away...I will write here if it is something related with undertow

richiardiandrea 2016-09-14T20:27:27.000076Z

So @jcrossley3 I have a question about this if you have time, it is not clear to me the reason of this behavior:

$ wscat -c <ws://localhost:3000>
connected (press CTRL+C to quit)
disconnected

richiardiandrea 2016-09-14T20:28:12.000077Z

I even checked Wireshark dumps and it looks like the server is sending a ACK+FIN right after the handshake completes successfully

2016-09-14T20:28:35.000078Z

have you confirmed that chrome or firefox works?

richiardiandrea 2016-09-14T20:28:43.000079Z

(I am using sente's adapter so I am just warning you that there might be many moving parts here)

richiardiandrea 2016-09-14T20:28:57.000080Z

yes the browsers are working fine

2016-09-14T20:29:12.000081Z

what about the http-kit sente adapter?

richiardiandrea 2016-09-14T20:29:18.000082Z

it is more for my own curiosity

richiardiandrea 2016-09-14T20:29:23.000083Z

let me check

2016-09-14T20:29:48.000084Z

sente may be expecting an initial payload or params, and closes when it doesn't see it

richiardiandrea 2016-09-14T20:29:59.000085Z

with no timeout at all?

richiardiandrea 2016-09-14T20:30:08.000086Z

mmm I need to check that as well

2016-09-14T20:30:17.000087Z

not if it expects it as part of the connection setup call

2016-09-14T20:30:20.000088Z

but I'm just guessing

richiardiandrea 2016-09-14T20:30:49.000091Z

there is a :timeout 0 there but I am not sure of what it does

2016-09-14T20:35:40.000092Z

0 means "never timeout": http://immutant.org/documentation/current/apidoc/immutant.web.async.html

👍 1
richiardiandrea 2016-09-14T20:36:30.000093Z

so it looks like the immutant side is ok

2016-09-14T20:39:38.000094Z

sente at least sends the client-id as a param on connection: https://github.com/ptaoussanis/sente/blob/master/src/taoensso/sente.cljc#L1007

richiardiandrea 2016-09-14T20:40:35.000096Z

yeah but that looks like the client side right?

richiardiandrea 2016-09-14T20:40:44.000097Z

my client is wscat

2016-09-14T20:40:54.000098Z

correct, but I suspect the server side is expecting that, and closing it when it doesn't see it

richiardiandrea 2016-09-14T20:40:57.000099Z

for this strange test 😄

richiardiandrea 2016-09-14T20:40:59.000100Z

oh

richiardiandrea 2016-09-14T20:41:22.000101Z

you might be right I am about to try putting there some more tracing

richiardiandrea 2016-09-14T21:13:11.000102Z

Mmm with undertow 1.4.0.Final I see some logs about sessions:

14:11:41.247 [XNIO-1 task-2] DEBUG io.undertow.websockets.core.request - Attempting websocket handshake with io.undertow.websockets.core.protocol.version13.Hybi13Handshake@66969f7c on HttpServerExchange{ GET / request {Connection=[Upgrade], Sec-WebSocket-Version=[13], Sec-WebSocket-Key=[MTMtMTQ3Mzg4NzUwMTIyOA==], Upgrade=[websocket], Sec-WebSocket-Extensions=[permessage-deflate; client_max_window_bits], Host=[localhost:3000]} response {Server=[undertow], Content-Type=[text/html; charset=utf-8]}}
14:11:41.247 [XNIO-1 task-2] DEBUG io.undertow.request - Upgrading request HttpServerExchange{ GET / request {Connection=[Upgrade], Sec-WebSocket-Version=[13], Sec-WebSocket-Key=[MTMtMTQ3Mzg4NzUwMTIyOA==], Upgrade=[websocket], Sec-WebSocket-Extensions=[permessage-deflate; client_max_window_bits], Host=[localhost:3000]} response {Server=[undertow], Content-Type=[text/html; charset=utf-8]}}
but then nothing else, it looks like it does not even hit sente (that has traces on as I can see them when using a browser...). Digging digging

richiardiandrea 2016-09-14T21:32:30.000104Z

with http-kit it is even more weird:

$ wscat -c <ws://localhost:3000>
error: Error: unexpected server response (200)
&gt;

richiardiandrea 2016-09-14T21:34:05.000105Z

but it looks like it is returning an html page for some reason...

richiardiandrea 2016-09-14T21:46:26.000107Z

so just because I might go crazy I am reporting here my findings...

clojure.lang.ExceptionInfo: Client's Ring request doesn't have a client id. Does your server have the necessary keyword Ring middleware (`wrap-params` &amp; `wrap-keyword-params`)? {:ring-req {:remote-addr "127.0.0.1", :params {}, :route-params nil, :headers {"connection" "Upgrade", "host" "localhost:3000", "sec-websocket-extensions" "permessage-deflate; client_max_window_bits", "sec-websocket-key" "MTMtMTQ3Mzg4OTUwMzM1NQ==", "sec-websocket-version" "13", "upgrade" "websocket"}, :async-channel #object[org.httpkit.server.AsyncChannel 0x7490c843 "/127.0.0.1:3000&lt;-&gt;/127.0.0.1:42988"], :server-port 3000, :content-length 0, :form-params {}, :websocket? true, :query-params {}, :content-type nil, :character-encoding "utf8", :uri "/chsk", :server-name "localhost", :query-string nil, :body nil, :scheme :http, :request-method :get}}
	at clojure.core$ex_info.invokeStatic(core.clj:4724)
	at clojure.core$ex_info.invoke(core.clj:4724)
	at 
[cut]

richiardiandrea 2016-09-14T21:46:32.000108Z

with wscat -c <ws://localhost:3000/chsk>

richiardiandrea 2016-09-14T21:46:48.000109Z

note the chsk at the end 🤦