These are chat archives for fanout/pushpin

6th
Nov 2015
Vipul
@v1p
Nov 06 2015 11:51
To be honest I am very new to WebSocket on the whole, I struggled to setup just a basic example app, that uses websockhop on client end & pushpin with a grails app at server end
none of the grip-control library examples states this basic setup, i.e. I need to setup an endpoint returning 101, along with Grip header from my server, when a connection is required to be open from client end.
perhaps this was a naive mistake, but I would love to learn from and contribute to a wiki, that helps in understanding the whole fanout suite
Vipul
@v1p
Nov 06 2015 14:46
Okie, so the problem that I figured out is that Pushpin isn't sending the Websocket-over-HTTP events to my server
Any pointers to debug this ?
Vipul
@v1p
Nov 06 2015 14:51
I have over_http setup in routes
Vipul
@v1p
Nov 06 2015 16:01
I started pushpin in verbose mode, at the end I get a "[WARN] 2015-11-06 21:20:51.572 zws: id=pushpin-m2-7999_1 error condition=rejected" in m2adapter.log ... Only thing that I am able to notice is that "Content-Type: application/websocket-events;charset=UTF-8" is the way this header is set... should that be a problem ? I mean the ';charset=..' part
Konstantin Bokarius
@kbokarius
Nov 06 2015 16:04
I recall running into something similar in the past working with a different language lib. The charset may or may not be an issue. @jkarneges thoughts?
@v1p can you share the rest of the code? Also are you setting the "Sec-WebSocket-Extensions" response header to "grip; message-prefix=""" on the origin server?
Konstantin Bokarius
@kbokarius
Nov 06 2015 16:14
@v1p I assume you're already doing so but you can use one of our other libs usage examples as pseudocode for how to use java-gripcontrol with websocket-over-http: https://github.com/fanout/ruby-gripcontrol
The methods names and parameters should be very similar if not identical.
Vipul
@v1p
Nov 06 2015 16:52
response.setHeader('Sec-WebSocket-Extensions', 'grip')
        response.characterEncoding = 'UTF-8'
        response.setHeader('Content-Type', 'application/websocket-events')
        response.setHeader('Accept', 'application/websocket-events')
        response.setStatus(200)
        render GripControl.encodeWebSocketEvents([
                new WebSocketEvent('OPEN'),
                new WebSocketEvent('TEXT', "c:${GripControl.webSocketControlMessage('subscribe', ['channel': 'all'])}")
        ])
This is what I am doing from an action inside a grails controller, reachable at http://localhost:8080/stream , proxy passed by pushpin with over_http set, at http://localhost:7999
I added 'Accept' just to debug & see if the headers were going correctly :) please ignore that
and this is debug log generated in m2adapter.log
[DEBUG] 2015-11-06 21:20:41.359 m2: IN pushpin-m2-7999 1 /stream 914:{"PATH":"/stream","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","cache-control":"no-cache","origin":"http://localhost:3000","accept-language":"en-US,en;q=0.8,hi;q=0.6","accept-encoding":"gzip, deflate, sdch","connection":"Upgrade","sec-websocket-version":"13","pragma":"no-cache","sec-websocket-key":"jxrZv1g0aCGXaq01sCtO3A==","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36","host":"localhost:7999","upgrade":"websocket","cookie":"connect.sid=s%3A4VdzyrxV39ACV1jVIPD5ude0gKppqJaK.iCz%2F3Yz%2FlyQm99d1AeilXJ5gd7h4ZM2r%2Fvd5pDQEQNo; XSRF-TOKEN=bohTmXUUSMIsgdT0MEVKW5ng%2BJMXO030WWbks%3D; JSESSIONID=7BE6F5AC1104F81BC3B3559778A65BE8; _ga=GA1.1.1668102029.1445014931; _gat=1","METHOD":"WEBSOCKET_HANDSHAKE","VERSION":"HTTP/1.1","URI":"/stream","PATTERN":"/","URL_SCHEME":"http","REMOTE_ADDR":"127.0.0.1"},28:MQ+smzJTqvZqeK/1fO55nLF5ANI=,
[INFO] 2015-11-06 21:20:41.360 m2: pushpin-m2-7999 id=1 request ws://localhost/stream
[DEBUG] 2015-11-06 21:20:41.360 zws: OUT T991:3:uri,21:ws://localhost/stream,3:seq,1:0#4:from,11:m2zws_75745,7:headers,840:42:15:Accept-Encoding,19:gzip, deflate, sdch,]46:15:Accept-Language,23:en-US,en;q=0.8,hi;q=0.6,]28:13:Cache-Control,8:no-cache,]24:10:Connection,7:Upgrade,]253:6:Cookie,239:connect.sid=s%3A4VdzyrxV39ACV1jVIPD5ude0gKppqJaK.iCz%2F3Yz%2FlyQm99d1AeilXJ5gd7h4ZM2r%2Fvd5pDQEQNo; XSRF-TOKEN=bohTmXUUSMIsgdT0MEVKW5ng%2BJMXO030WWbks%3D; JSESSIONID=7BE6F5AC1104F81BC3B3559778A65BE8; _ga=GA1.1.1668102029.1445014931; _gat=1,]25:4:Host,14:localhost:7999,]34:6:Origin,21:http://localhost:3000,]20:6:Pragma,8:no-cache,]74:24:Sec-Websocket-Extensions,42:permessage-deflate; client_max_window_bits,]49:17:Sec-Websocket-Key,24:jxrZv1g0aCGXaq01sCtO3A==,]30:21:Sec-Websocket-Version,2:13,]22:7:Upgrade,9:websocket,]139:10:User-Agent,120:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36,]]12:peer-address,9:127.0.0.1,2:id,17:pushpin-m2-7999_1,7:credits,6:200000#}
[DEBUG] 2015-11-06 21:20:51.572 zws: IN T561:4:body,55:OPEN
TEXT 26
c:{"channel":"all","type":"subscribe"}
,9:condition,8:rejected,6:reason,2:OK,3:seq,1:0#4:from,19:pushpin-proxy_75747,7:headers,349:30:6:Server,17:Apache-Coyote/1.1,]35:27:Access-Control-Allow-Origin,1:*,]43:32:Access-Control-Allow-Credentials,4:true,]35:24:Sec-WebSocket-Extensions,4:grip,]41:6:Accept,28:application/websocket-events,]62:12:Content-Type,42:application/websocket-events;charset=UTF-8,]31:17:Transfer-Encoding,7:chunked,]40:4:Date,29:Fri, 06 Nov 2015 15:50:51 GMT,]]4:type,5:error,2:id,17:pushpin-m2-7999_1,4:code,3:200#}
[WARN] 2015-11-06 21:20:51.572 zws: id=pushpin-m2-7999_1 error condition=rejected
[DEBUG] 2015-11-06 21:20:51.573 m2: OUT [pushpin-m2-7999 1:1, HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Sec-WebSocket-Extensions: grip
Accept: application/websocket-events
Content-Type: application/websocket-events;charset=UTF-8
Date: Fri, 06 Nov 2015 15:50:51 GMT
Content-Length: 55

OPEN
TEXT 26
c:{"channel":"all","type":"subscribe"}
]
[DEBUG] 2015-11-06 21:20:51.573 m2: OUT [pushpin-m2-7999 1:1, ]
Konstantin Bokarius
@kbokarius
Nov 06 2015 17:12
Hmm the charset=UTF-8 may be the issue. Is it possible for you to remove it? I vaguely remember running into the same issue many months ago although I'm not 100% sure if removing it resolved the issue.
Also have you tried appending message-prefix="" to the Sec-Websocket-Extensions header? You may not need it but I've always added it in my testing. I send 'grip; message-prefix=""'
Vipul
@v1p
Nov 06 2015 17:15
Let me try that as well
Vipul
@v1p
Nov 06 2015 17:52
I am not sure what's wrong but grails isn't allowing me to remove charset from Content-Type header. Also, I tried message-prefix = "" as well, to no avail
Justin Karneges
@jkarneges
Nov 06 2015 18:24
yes i think it's the charset. there ought to be a way to remove that, since it's nonsense in the context of this content type
i can also see about making pushpin more lenient
fwiw, the reason i say charset is nonsense is because the websocket-over-http format may contain mixed binary (e.g. BINARY or CLOSE frames), so the response technically isn't utf-8 parsable
Vipul
@v1p
Nov 06 2015 18:31
I agree, I am finding a way to register a custom mime type to bypass this auto-append of charset in grails
Vipul
@v1p
Nov 06 2015 22:14
Weew! got it working, yes it definitely doesn't make sense for the charset to be present for mixed binary content. This is working code now for making the endpoint talk to Pushpin :smile:
response.setHeader('Sec-WebSocket-Extensions', 'grip; message-prefix=""')
        response.contentType = 'application/websocket-events'

        String responseMessage = GripControl.encodeWebSocketEvents([
                new WebSocketEvent('OPEN'),
                new WebSocketEvent('TEXT', "c:${GripControl.webSocketControlMessage('subscribe', ['channel': 'all'])}")
        ])
        response.outputStream << responseMessage
        response.outputStream.flush()
Thanks @kbokarius & @jkarneges ! :beers:
Justin Karneges
@jkarneges
Nov 06 2015 22:17
awesome!