These are chat archives for fanout/pushpin

8th
Dec 2015
Raunak Kathuria
@raunakkathuria
Dec 08 2015 06:44

We at binary.com are trying to implement pushpin using WebSocket-over-HTTP protocol. As of now for testing this is our routes file entry * localhost:1337,over_http

We need clarifications for two scenario

Scenario 1

Client<<------Websocket(persistent)--------->>Pushpin<<- - - - - http(short lived) - - - - >>Backend
  • how can our origin server know if client and pushpin websocket connection closes, for example if client side loses the network.
  • We saw request headers in case of open and close request we receive from pushpin but couldn't find any key to distinguish between two

Scenario 2

Say if we are streaming i.e server side events to particular channel (if our channel are based on connection-id we receive in request headers, for example 'Connection-Id':'6760072f-3bc9-4870-a7be-b6ebfb7bc411') and pushpin crashes in between then how our backend/server would know if that channel is dead so that we can stop our streaming

Justin Karneges
@jkarneges
Dec 08 2015 08:19
hi @raunakkathuria . you'll get a DISCONNECT event once the TCP connection times out (but this could take awhile). otherwise you'll almost always get CLOSE for a clean disconnect
you can use the Connection-Id header to track a connection. if your goal is to avoid publishing events to channels without listeners, then tracking channels is better (usually tracking connections is not needed)
Justin Karneges
@jkarneges
Dec 08 2015 08:26
tracking channels requires connecting to one of pushpin's zmq sockets (either the push SUB socket or stats PUB socket)
Justin Karneges
@jkarneges
Dec 08 2015 08:41
here's a python example for connecting to the push SUB socket: https://gist.github.com/jkarneges/d3179119cdb412da9daa
Raunak Kathuria
@raunakkathuria
Dec 08 2015 09:36

@jkarneges thanks for the reply, can you explain this further

you can use the `Connection-Id` header to track a connection. if your goal is to avoid publishing events to channels without listeners, then tracking channels is better (usually tracking connections is not needed)

for example when pushpin sends request with connection-id=xyz and server uses this channel for server side events. Now suddenly pushpin crashes (in this case it will not send any close event) and now server pushes an event to xyz channel, will pushpin reply with some error so we can stop streaming of events?

Justin Karneges
@jkarneges
Dec 08 2015 09:52
there are no error replies to a publish. what you can do is track channels separately, and only publish if a channel has a subscription
Raunak Kathuria
@raunakkathuria
Dec 08 2015 09:53
and one more thing how i can print out request, response of pushpin, is there any verbose mode?
Justin Karneges
@jkarneges
Dec 08 2015 09:53
it is also possible to track connections more reliably, by using keep alives. if you respond with a header like Keep-Alive-Interval: 60, then pushpin will issue an http request to the backend for that connection every 60 seconds. so you can assume a connection is closed if that time elapsed
Raunak Kathuria
@raunakkathuria
Dec 08 2015 09:54
ok thanks will use that
Justin Karneges
@jkarneges
Dec 08 2015 09:54
if you run pushpin with --verbose then all the log files will get more verbose. pushpin-proxy.log is the one that you'd probably want to see
Raunak Kathuria
@raunakkathuria
Dec 08 2015 09:55
thanks a lot for your help
Justin Karneges
@jkarneges
Dec 08 2015 09:56
sure thing. i'm curious, will this be for a public API?
Raunak Kathuria
@raunakkathuria
Dec 08 2015 09:56
yes this will be for public API
Justin Karneges
@jkarneges
Dec 08 2015 09:57
very cool :)